Server IP : 172.16.15.8 / Your IP : 3.147.86.143 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/jljustice/cs212/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
// // // // the progrm will define student class and its client code // (driver) // // #include <iostream> #include <iomanip> using namespace std; // p.119 class Student { private: //data members string name; int test1, test2, final; public: // (interface) fun. members void Set(string n, int t1, int t2, int f) // transformer { name = n; test1 = t1; test2 = t2; final = f; } void Print() const // observer { cout << "Name: " << name << endl; cout << "Test1: " << test1 << endl; cout << "Test2: " << test2 << endl; cout << "Final: " << final << endl; cout << "Average: " << Average() << endl; } // define Average fun_member to return the avg score float Average() const { return (test1 + test2 + final)/3.0; } }; //client code int main() { //Q: declare a Student object stu1 Student stu1; //Q: set stu1 to: "Joe Smith", 62, 73, 97? stu1.Set("Joe Smith", 62, 74, 97); //Q: display info about stu1? cout << fixed << showpoint << setprecision(1); stu1.Print(); cout << "\n\n Done.\n\n"; return 0; }