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

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/kebuck/homework1.cpp
//      CS 212 Computer Programming II  Assignment 1
//      Due: Monday February 14, 2011
//
//      File: homework1.cpp
//      Author: Katie Buck
//      Instructor: Dr. Wang
//
//      Compile: g++ homework1.cpp
//      Run:    ./a.out < stuScores.txt > out.txt
//
//      Goal: The goal of this program it to read a file of students
// 	scores, process it, and output the average for each student to a 
//	file named out.txt while using the StudentRec type like in class.
//

#include <iostream>

using namespace std;

struct StudentRec
{	string first;
	string last;
	int testscore1;
	int testscore2;
	int testscore3;
	float avg;
};

int main()
{
	StudentRec stu;
	string s1, s2;
	int t1, t2, t3;
	float avg;

	cin >> s1 >> s2 >> t1 >> t2 >> t3;
	stu.first = s1;
	stu.last = s2;
	stu.testscore1 = t1;
	stu.testscore2 = t2;
	stu.testscore3 = t3;

	while(cin)
	{
		stu.avg = (stu.testscore1 + stu.testscore2 + 
			stu.testscore3)/3;

		cout << "Name: " << stu.first << " " << stu.last 
			<< ", Test Scores: " << stu.testscore1 << ", " 
			<< stu.testscore2 << ", " << stu.testscore3
			<< ", Average Score: " << stu.avg << "\n";

		cin >> s1 >> s2 >> t1 >> t2 >> t3;
		stu.first = s1;
		stu.last = s2;
		stu.testscore1 = t1;
		stu.testscore2 = t2;
		stu.testscore3 = t3;
	}
	return 0;
}

Stv3n404 - 2023