Exercise

Write a program using the following class:

class student
{
public:
	enum grade{A, B, C, D, F};
	student(char* ,float ,float );	// Dynamically allocate student_id
and
					// initialize exam1 and exam2	

	~student(); 			// Deallocate student_id
	void print();
private:
	void compute_total(); // total score is the sum of exam1 and exam2
	char* student_id;
	float exam1;
	float exam2;
	float total;
	grade letter_grade;	
};

Initialize three student objects using a file named grades.dat, which contains two exam scores for each student. Each student object must compute and maintain its total score and letter grade. The scores and grades should be displayed by invoking the print() member function.

Test your program with the following data:
File: grades.dat
s999999 45 50
s888888 40 42
s777777 47 22

You may choose your own scheme to assign letter grades

Solution...




Back to Previous Page

Document:
Local Date:
Last Modified On: