Server IP : 172.16.15.8 / Your IP : 18.116.12.7 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/bnhans/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
// hint for assigntment 2 // #include <iostream> using namespace std; class Student { string name1, name2; int test1, test2, test3; float avg; public: Student() { } void Set(string n1, string n2, int t1, int t2, int t3) { name1 = n1; name2= n2; test1 = t1; test2 = t2; test3 = t3; } int Sum() const // sum up individual students { int s = test1 + test2 + test3; return s; } int Average() const { float a = (test1 + test2 + test3 ) / 3.0; return avg; } void Print() const { cout << "Name: " << name1 << " " << name2 << " , " << test1 << " , " << test2 << " , " << test3 <<" , Sum: " << Sum() << "\n"; } }; int main() { Student stu; string n1, n2; // for first last name int t1, t2 , t3; //for test; int counter = 0; int sum = 0; cin >> n1 >> n2 >> t1 >> t2 >> t3; stu.Set(n1, n2, t1, t2, t3); stu.Print(); while (cin) { cout << "Name: " << n1 << " , " << n2 << " " << t1 << " , " << t2 << " , " << t3 << " , " << " , Averages: " << stu.Average() << "\n"; cin >> n1 >> n2 >> t1 >> t2 >> t3; stu.Set(n1,n2,t1, t2, t3); } cout << "The average of all scores is: " << (sum) /counter++ << "\n\n"; stu.Print(); return 0; }