![]() |
![]() |
|
Last modified:
Change log:
tip: In class last semester we came up with this list of steps for this assignment.
This program will help you learn how to
Your program should produce output similar to the following:
Sample 1: rucs:ibarland/itec320/hw01> ./gradepoints
My name: Joe Jones
Hours: 30
GPA: 3.500
Grade Points: 105.0
Points above: 45.0
Sample 2: rucs:ibarland/itec320/hw01> gradepoints
My name: Jack Spratt
Hours: 40
GPA: 1.500
Grade Points: 60.0
Points below: 20.0
Program to Modify: Modify the program below so that it reflects you.
-- File: gradepoints.adb -- Name: -- Date: -- Purpose: Calculate points surplus or deficit -- based on hours taken and GPA with Ada.Text_IO; use Ada.Text_IO; with Ada.Float_Text_IO; use Ada.Float_Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; procedure gradepoints is -- Personal data to be modified name: constant String := "Joe Jones"; -- Student name hours_attempted: constant Natural := 30; -- Hours taken gpa: constant Float := 3.5; -- Current GPA -- End of personal data to be modified earned_points: Float; -- Points actually attained -- Requirements Required_GPA: constant := 2.0; -- GPA required to graduate required_points: Float; -- Points needed to graduate -- Points calculations surplus, deficit: Float; -- Points above or below required begin -- Calculation earned_points := Float(hours_attempted) * gpa; required_points := Required_GPA * Float(hours_attempted); -- Calculate both even though one will not be needed surplus := earned_points - required_points; deficit := required_points - earned_points; -- Output put_line("Name: " & name); put_line("Hours:" & hours_attempted'img); put("GPA: "); put(item => gpa, fore => 1, aft => 3, exp => 0); new_line; put("Grade Points: "); put(earned_points, 1, 2, 0); new_line; -- Surplus or deficit if earned_points = Required_GPA then put("Exact: "); put(gpa, fore => 1, aft => 2, exp => 0); new_line; elsif earned_points >= Required_GPA then put("Points above: "); put(surplus, fore => 1, aft => 2, exp => 0); new_line; else put("Points below: "); put(deficit, fore => 1, aft => 2, exp => 0); new_line; end if; end gradepoints; |
Creating your adb file: Your data file can be created with any editor, but don't use an editor (such as wordpad) that stores characters using 16 rather than 8 bits. Also don't use an editor that creates an RTF (ie rich text) file. If you use AdaGIDE or GPS, then this will not be a problem.
Compilers: The Ada compiler gnat and the Ada IDE's AdaGide and GPS are installed on department machines. AdaGide is easier to use, but GPS has more features. You can also use the gnat compiler using the command line with a local shell or by using a terminal window (eg putty) to login to a local Linux machine called rucs. To use putty from off campus you must first be running a VPN session.
You may also want to install these tools on your personal machine. The site www.adacore.com/community has a installers for the GNAT compiler (which also installs gps) for a variety of platforms. AdaGIDE is available from adagide.martincarlisle.com. Make sure that you install gnat before installing adagide. An Eclipse plugin is available from the Adacore site. Another source for gnat is getadanow.com.
More instructions on compilers is available here and here
Submission: ibarland section Submit the one file gradepoints.adb in the D2L dropbox.You do not need to submit any data files.
This page licensed CC-BY 4.0 Ian Barland Page last generated 2018.Aug.31 (Fri) | Please mail any suggestions (incl. typos, broken links) to ibarland ![]() |