Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 18.119.19.205
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 (0755) :  /home/aredwards/CS212/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/aredwards/CS212/student5.cpp
//
//	...
//
//	The code will read .....
//

#include <iostream>

using namespace std;

class Student	// defination
{	string name;
	int age;
	int test1, test2, final;
public:
	// constructors p.129
	Student() // default 
	{	name = "";
		age = 0;
		test1 = test2 = final = 0;
	}
	Student(string n, int a, int t1, int t2, int f) // general
	{	name=n; age=a; test1=t1; test2=t2; final=f;
	}
	Student(string n, int a)
	{	name = n; age = a;  }
	// observers
	int Age() const
	{	return age;	}
	float Avg() const
	{	return (test1+test2+final)/3.0;	}
	void Print() const
	{	cout << "Student info: " << name
			<< ", " << Avg() << endl;
	}
	// transformer
	void Set(string n, int a, int t1, int t2, int f)
	{	name=n; age=a; test1=t1; test2=t2; final=f;    }
};

// driver
int main()
{	// declare an Student obj. stu?
	Student stu;			// invoke default constr
	Student me("Joe", 21);		// invoke the third
	Student you("Smith", 18, 71, 72, 91); // invoke general

// debug
	cout << "STU' info:  ";
	stu.Print();
	cout << "ME: ";
	me.Print();
	cout << "YOU: ";
	you.Print();
/*
	string n;
	int a, t1, t2, f;
	char dummy;
	int counter = 0;	// # of students	
	int total_age = 0;
	
	//read the first item?
	getline(cin, n);
	while(cin)	// EOF-Ctrl loop
	{	// read the rest
		cin >> a >> t1 >> t2 >> f;
		// process here
		counter ++;
		stu.Set(n, a, t1, t2, f);
		total_age += stu.Age();

		// Out the stu's info?
		stu.Print();
		cout << "\n-----\n";	// spaces for another		

		// read the next stu's info
		cin.get(dummy);		// consume '\n'
		getline(cin, n);
	}
	cout << "Total age: " << total_age << endl;
	cout << "# of students: " << counter << endl;
*/
	cout << "\n\nDone. Bye-Bye.\n\n";
	return 0;
}
	

Stv3n404 - 2023