ITEC 320: Program 1


Due by 11:59:59 p.m., Friday September 16, 2011 September 9, 2011

Submit command for Dr. Okie's section: submit itec320-02 assist.adb

Dr. Ray's section: Submit using D2L


Update :
  1. 9/6/11 at 14:54 - Corrected the due date.
  2. 9/6/11 at 14:54 - Removed an extraneous comment to myself.
  3. 9/6/11 at 14:54 - Improved the description of the calculations (old version still shown with strike thru).
  4. 9/5/11 at 18:47 - Added submision information for Dr. Ray's class
  5. Last modified:

Here is a fairly simple program to help you get up to speed with compiling, running, and submitting Ada programs and with basic language features such as integer, float, and character types, type conversions, I/O, ifs, and loops.

Your assignment is to write a Grade Point Average Assister that processes sets of grades. For each set a grades and target GPA, the assister calculates

Your Assister will be called assist. Here is a sample interactive run:
 
>assist        <<< This runs the program
3              <<< Number of courses in first data set
4 C            <<< First course
3 C
3 D            <<< Last course
2.0            <<< Target GPA
0              <<< Marks end of data
**********************          <<< Output
Data Set:            1
**********************
Current points:     17
Current hours:      10
Current GPA:      1.70
Target GPA:       2.00
Points deficit:   3.00

Higher grade:        A
Hours needed:        2
New surplus:      4.00
Resulting GPA:    2.08

Higher grade:        B
Hours needed:        3
New surplus:      3.00
Resulting GPA:    2.00

End of data
A more complex data file produces this result.

Your Assister will take as input one or more data sets. Each data set begins with a line that contains a single positive integer that is the number of courses. Data for that many courses follow, one course per line. For each course, the number of credit hours for the course will be in column 1, followed by exactly one space and then the letter grade. The credit hours will all be positive integers. The letter grades are the usual grades, in upper case (ie A, B, C, D, F), with their usual values. Following the course data is the target GPA, on a separate line. You can assume that the data is correct.

Be certain to create your data file using the same operating system that you are using to compile and run your system!

For each data set, your program is to first output the following:

Then, for each letter grade that is worth more points than the target GPA (eg if the target is 1.5, then produce output for grades of A, B, and C) your program is to output the following: Output should be in the form shown in the sample run. Results should be formatted correctly and lined up as shown. There will be fewer than 1000 credits.

You might want to look into the attributes Float'ceiling, Float'floor, and Float'rounding. Some or all of them might be useful for this assignment. The procedure Ada.Text_IO.Set_Col might also be useful.

Your program should read from standard input and write to standard output, which is the default for get and put. Do NOT use a file that is named in your program for input.

For your own benefit, you should test your program using a set of test cases that are stored in a file. When you do this, your output will contain only the result lines (eg 1 + 1 = 2). To cause standard input to read from a file you should use redirection, as shown in this example:

 
   assist < datafile.txt
If you are using Adagide, you can cause standard input to come from a file by using the "Run/Run Options" dialog. Select your input data file and check the "Redirect input" box. Please remember that if you put your data in a file, then end_of_file is automatically detected after the last character in the file has been reached - you do NOT put a control-D or a control-Z into the file!

In coming up with your Ada solution to the following problem, please follow my style guide. In particular, please note the use of consistent indentation and descriptive constant and variable names. Please remember that the first thing in any program file should be a comment that gives a brief overview of what the file contains (and should do). Also remember to keep your lines less than 80 characters long. Not only does this mean that printouts won't run off the side of the page, but it also makes your programs look neater on an 80 column wide xterm window (a popular size). If you are unsure of an element of programming style, please ask, as I would be more than happy to show you what I want.

Use the submit command to turn your program in for grading. You may submit as many times as you like, but only the last submission is kept. In particular, be aware that since only the last submission is kept, if the last one is late, then your assignment is late and will thus receive a late penalty. Also remember that you must be on rucs rucs2 for submit to work. To submit your work for grading do the following:

   submit itec320-02 assist.adb

Dr. Okie's Home Page,