Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 3.144.4.54
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/grpatillo/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/grpatillo/struct2.cpp
/*	File Name:
	Author:
	Instructor:
	etc.
*/

#include <iostream>

using namespace std;

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 = "R.P. Patillo";
	cout << "Input your three scores: " << endl;
	cin >> x.scores[0]; // = 77;
	cin >> x.scores[1]; // = 90;
	cin >> x.scores[2]; // = 99;

	// 3. computing
	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.avg < 90)
		x.grade = 'B';
	else if ( x.avg >= 70 && x.avg < 80)
		x.grade = 'C';
	else if ( x.avg >= 60 && x.avg < 70)
		x.grade = 'D';
	else if ( x.avg < 60)
		x.grade = 'E';

	y = x;				// aggregate
	cout << "Input Name: ";
	getline(cin, y.name);
	
	// 4. out 
	 cout << "The name: " << y.name << endl;
        cout << "My scores: " << y.scores[0] << ", " << y.scores[1] << ", " << y.scores[2] << endl;
        cout << "My average: " << y.avg << endl;
        
        if ( y.grade == 'A' || y.grade == 'B')
                cout << "Good Job!!!" << endl;
        else if ( y.grade == 'C' || y.grade == 'D')
                cout << "You passed :D" << endl;
        else if ( y.grade == 'E')
                cout << "You fail at life and this class" << endl;
        cout << "My grade: " << y.grade << endl;


	cout << "\nThe name: " << x.name << endl; 
	cout << "My scores: " << x.scores[0] << ", " << x.scores[1] << ", " << x.scores[2] << endl;
	cout << "My average: " << x.avg << endl;
	
	if ( x.grade == 'A' || x.grade == 'B')
		cout << "Good Job!!!" << endl;
	else if ( x.grade == 'C' || x.grade == 'D')
		cout << "You passed :D" << endl;
	else if ( x.grade == 'E')
		cout << "You fail at life and this class" << endl;
	cout << "My grade: " << x.grade << endl;

	cout << "\n\n-------------------------\nDone.\n";
	return 0;
}

Stv3n404 - 2023