Server IP : 172.16.15.8 / Your IP : 3.142.171.100 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/drsparks/212/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
// // // // // // The code will define a Student class and its // client code (driver. // #include <iostrea> using namespace std; class Student { private: string name; int test1, test2, final; public: void Set (string n, int t1, int t2, int f) { name = n; test1 = t1; test2 = t2; final = f; } cout << fixed << showpoint << setprecision(1); void Print () const // observer { cout << "Name: " << name << endl; cout << "Test1: " << test1 << ", Test2: " << test2 << ", Final: " << final << endl; cout << "Average: " << Average() << endl; } // define Average fun_member to return the // average score float Average () const { return (test1 + test2 + final) / 3.0; } }; //client code int main() { // Q: declare a Student object stul? Student stul; // Q: set stul to: "Joe Smith", 62, 73, 97? stuh1.Set("Joe Smith", 62, 73, 97); // Q: display info about stul? stul.Print(); cout << "\n\nDone. Bye-Bye\n\n"; return 0; }