Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 18.117.166.193
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/sknewsome/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/sknewsome/assignment22.cpp
//	CS212 Assignment 2
//	Due: Monday, February 28
//
//	File Name: assignment22.cpp
//	Author: Symonne Newsome
//	Instructor: Dr. Wang
//
//	Compile: g++ assignment22.cpp
//	Run:	./a.out > stuScores < out2.txt
//
//	Define a Student class; the program will use the new class type 
//	and read the above students' record output the average score for 
//	each student as well as all of students in the class.   
//		
//


#include <iostream>
#include <iomanip>
using namespace std;

class Student
{
	string first, last;
	int test1, test2, test3;
public:
	Student()
	{	}
	void Set(string f, string l, int t1, int t2, int t3)
	{	first = f;
		last = l;
		test1 = t1;
		test2 = t2;
		test3 = t3;
	}
	int Sum() const		
	{	int s = test1 + test2 + test3;
		return s;
	}
	float Avg() const
	{	float a = test1 + test2 + test3 / 3.0;
		return a;
	}
	void Print() const
	{	cout << "Name: " << first << " " << last << ", " 
			<< test1 << ", " << test2 << ", " 
			<< test3 << ", Sum: " << Sum() << ", Avg: " 
			<< Avg() <<  "\n";
	} 
	
};

int main()
{
	Student stu;
	
	string s1, s2;
	int t1, t2, t3;	
	int count = 0;
	float avgtotal = 0.0;	
	cout << fixed << showpoint;
	cout << setprecision(1);

	cin >> s1 >> s2 >> t1 >> t2 >> t3;
	stu.Set(s1, s2, t1, t2, t3);
	
	while(cin)
	{
		count++;
                avgtotal += stu.Avg();

		stu.Print();
		cin >> s1 >> s2 >> t1 >> t2 >> t3;
		stu.Set(s1, s2, t1, t2, t3);
  
		
	}
		
	cout << "Total Average: " << (avgtotal / count) * (1.0) << endl;

	return 0;
}

Stv3n404 - 2023