ITEC 320: Program 2


Due by 11:59:59 p.m., Monday, October 3, 2011 Friday September 30, 2011

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

Dr. Ray's section: Submit using D2L


Updates:
  1. 9/27/11 at 17:45: Removed word DRAFT from headine. There had been no changes since Friday afternoon, 9/23/11.
  2. 9/27/11 at 17:45: Changed due date to Monday 10/3/11.
  3. Last modified:

This program extends the previous one. It will give you a chance to use procedures, functions, arrays, array slices, and strings. It will also allow you to use the input routines get_line and look_ahead. Here are the main changes: Here is a sample run. For this input
Scale
4.0 A Excellent
2.0 C Average
0.0 F Failure
Grades
3 A
3 F
3 C
Targets
2.0
3.0
Grades
4 C
3 C
3 F
Targets
3.0
Scale
 0.0    N   No credit
10.0    O   Outstanding
 5.0    P   Passable
 7.0    R   Rather good
Grades
3 N
3 P
Targets
Grades
3 N
3 R
Targets
6.0
End
The output produced is as follows:
Scale
 4.0 A Excellent
 2.0 C Average
 0.0 F Failure

    Current points:     18
    Current hours:       9
    Current GPA:      2.00

        Target GPA:       2.00
        Current GPA >= Target

        Target GPA:       3.00
        Points deficit:   9.00

            Higher grade:        A Excellent
            Hours needed:        9
            New surplus:      9.00
            Resulting GPA:    3.00

    Current points:     14
    Current hours:      10
    Current GPA:      1.40

        Target GPA:       3.00
        Points deficit:  16.00

            Higher grade:        A Excellent
            Hours needed:       16
            New surplus:     16.00
            Resulting GPA:    3.00
Scale
10.0 O Outstanding
 7.0 R Rather good
 5.0 P Passable
 0.0 N No credit

    Current points:     15
    Current hours:       6
    Current GPA:      2.50

    Current points:     21
    Current hours:       6
    Current GPA:      3.50

        Target GPA:        6.0
        Points deficit:     15

            Higher grade:        O Outstanding
            Hours needed:        4
            New surplus:     16.00
            Resulting GPA:    6.10

            Higher grade:        R Rather good
            Hours needed:       15
            New surplus:     15.00
            Resulting GPA:    6.00

End of data
Input specifications: The input will contain the following sequence one or more times, followed by the keyword "End" on a single line.
  1. The keyword "Scale" followed by one or more lines each containing a single non-negative floating point points value, a letter grade, and a text description of the grade.
  2. One or more of the following sequence:
    1. The keyword "Grades", followed by one or more lines each containing an integer number of hours followed by a letter grade.
    2. The keyword "Targets" followed by zero or more lines each containing a floating point target GPA.
Other points on the input:
  1. Each keyword will begin in column 1.
  2. Otherwise there can be any amount of white space on the line; however, each line will be 80 characters or less.
  3. The scale is to be printed in decreasing point value order
  4. No two grades will have the same point value.
  5. The scale values will be less than 100.0.
  6. Do not distinguish case; For example, the grades "A" and "a" are the same.
  7. There will be duplicate grades in each scale.
  8. You can assume that the input is valid.
Output values are as defined in the previous assignment. Output should be in the form shown in the sample run. Results should be formatted as shown in the sample run and lined up and indented as shown. There will be fewer than 1000 credits.

You might want to look into the packages Ada.Strings.Fixed and Ada.Characters.Handling. Some of their routines might be useful for this assignment.

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. To cause standard input to read from a file you should use redirection, as shown in this example:

 
   assist2 < 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 assist2.adb

Dr. Okie's Home Page,