Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 3.145.40.121
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/slcebula/cs207/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/slcebula/cs207/assignment2.cpp
//Author:       Lee Cebula
//Title:        assignment2.cpp
//Due Date:     2/6/08
//Compiling:    g++ assignment.cpp
//Execution:    ./a.out
//Goal:         Do structs and assignment2.

#include <iostream>
#include <iomanip>

using namespace std;

struct Student
{
        string name;
        int test1, test2, final;
        int age;
        float avg;
};

int main()
{
	//1. Declare Objects or variables
	Student someone;
	char dummy;
	float classtotal = 0;
	int classsize = 0;
	float agetotal;
	float classavg;
	float ageavg;

	cout << fixed << showpoint << setprecision(1);

	//2. Input
	cout << "Input the name of the student: ";
	getline(cin, someone.name);
	
	while(cin)
	{
		cout << "Input your three exam scores: ";
		cin >> someone.test1 >> someone.test2 >> someone.final;
		cout << "Input your age: ";
		cin >> someone.age;
		cin.get(dummy);

		//3. Compute
		someone.avg = (someone.test1 + someone.test2 + someone.final)/float(3);
		classsize ++;
		classtotal += someone.avg;
		agetotal += someone.age;

		//4. Ouput
		cout << "Name: " << someone.name << endl;
		cout << "Test1: " << someone.test1 << endl;
		cout << "Test2: " << someone.test2 << endl;
		cout << "Final: " << someone.final << endl;
		cout << "Age: " << someone.age << endl;
		cout << "Average: " << someone.avg << endl;

		cout << "Input the name of the student(Ctr + D to finish): ";
		getline(cin, someone.name);
	}
	classavg = classtotal / float(classsize);
	ageavg = agetotal / float(classsize);

	cout << "\n\nThe class average is: " << classavg << endl;
	cout << "The age average is: " << ageavg << endl;

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

Stv3n404 - 2023