CIS 122: Assignment #6

Due on Wednesday, August 10, 2005


Problem 1 (80 points)

You are given a file scores.dat containing the scores for all the students in CIS 110 in the term Spring 2006. Each line of the file is the entry for each student, with the format:

LAST_NAME, FIRST_NAME assign1 assign2 assign3 assign4 assign5 quiz1 quiz2 final

You are supposed to write a program, which

  1. Read data from scores.dat, for every student, calculate her/his final grade and corresponding letter grade, and write the information out to a new file named grades.dat. The format of each line is:

    LAST_NAME, FIRST_NAME final_grade letter_grade

    For example:

    GREEN, EMILY 97 A+

    Relative weights for the final grade are as follows:

    You should remember that the total possible scores for each quiz are 60, every assignment and the final have total possible scores of 100. And some student may get more than 100 for some assignments, because of extra credits.

    To assign the letter grades, check the following table:
    • 96 - 100  .........  A+
    • 90 - 95  ..........  A
    • 88 - 89  ..........  A-
    • 80 - 87  ..........  B
    • 78 - 79  ..........  B-
    • 75 - 77  ..........  C+
    • 70 - 74  ..........  C
    • 68 - 69  ..........  C-
    • 60 - 67  ..........  D
    • 0 - 60  ...........  F


  2. After you have finished the output to grades.dat, write another program (or add to the previous program) to find the highest final grade achived, and then print the name, final score, and the letter grade of everyone who earned that grade. (Notice that there can be more than one student earning that score, and you will never know how many! So use vector!) One example is:
    Highest score: 97
    Achieved by:
    		GREEN, EMILY 97 A+
    		PURPUS, JOHN 97 A+
    
Problem 2 (20 points)

Here is the interface of the Time class as given in the file time.h.

class Time
{
	public:
		void set(int h, int m, char mrd);
			// Set calling object's time
			// where 1 <= h <= 12, 0 <= m <= 59
			// and mrd is 'a', 'A', 'p', or 'P'
			// Exmaple: the call clock.set(2, 30, 'A')
			// sets clock to 2:30 AM.

		void update(int h, int m)
			// Change calling object's time by h hr and m min.
			// Example: if clock's time is 2:30 AM, the
			// call clock.update(4,15) will change it to
			// 6:45AM

		void display()
			//Display calling object's time on the monitor
			//Example: clock.display() will display time

	private:
		int hr, min
		char merid;
		void validate();


}
The following is a program using Time class, and a sample run of it. Fill in the blank line to finish the program and output.
#include <iostream>
#include "time.h"

using namespace std;

int main
{
	Time clock;
	int min_elapsed;
	___________________________________
	___________________________________
	cout << endl;
	cout << "Please input how many minutes elapsed: ";
	cin >> min_elapsed;
	___________________________________
	cout << "Now new time is ";
	clock.display();
	cout << endl;
	return 0;

}
The output:
9:56 AM
Please input how many minutes elapsed: 150
__________________________________

Standards:

Your program will be judged primarily on its correctness. In particular, the program must compile. Programs that do not will receive a severe grade penalty. Over and above this is the requirement of correct behavior: the cubic volume reported must be correct.

Third, there is presentation: prompts should be formatted neatly (exactly matching the example here is good). Both of the two output numbers provided should have two decimal places, which means, they have a precision of two digits after the decimal point.

Finally, your program will be judged on elegance and adherence to the principles of good programming style. Elegance means that there should be nothing there that isn't necessary for the computation: all variables should have a use, as should all assignments to those variables. Style refers to the proper use of indentation, information variable names, documentation with comments, and other matters of readability.

Turn in:


Dan Rao
Last modified: Wed August 3 23:22:34 PDT 2005