I really need help in writing this program for homework.
- Round the average for each student to the nearest integer.
- Add code to print out an appropriate message for each student. (given in prologue comments)
- Add code to calculate the highest student average, and the lowest student average.
- Add code to determine the number of students in each message category..
- At the conclusion of the while (inData) loop, print out the number of students processed, the highest student average, the lowest student average, and the number of students in each message category.
This is what I have so far, not much but I declared some variables:
// Program processes any number of students.
// Program inputs student name and test scores from a file.
// It calculates the average of the scores and
// prints a message depending on the score
// average >= 95 Oh Yes !
// average < 60 Oh NO !
// 60 <= average < 95 Okay!
// Data for each student is on two line
// first line:<firstname > <lastname > <number of scores>
// second line: integer scores separated by blanks
// Sample data lines for one student:
// Alec Anderson 5
// 90 70 88 60 95
#include<iostream>
#include <string>
#include<fstream>
#include <iomanip>
using namespace std ;
int main()
{
string first, last;
int sum, //sum of scores for one student
num, // number of tests for one student
score, // student score
count, // loop control variable
average, // average for one student
rounded;
ifstream inData; //input file stream variable
cout << "Enter first and last name: ";
cin >> first >> last;
cout << "\nEnter the number of scores: ";
cin >> score;
cout << "\nEnter integer scores separated by blanks: ";
cin >> score;
inData.open("Self_paced.txt");
if( !inData)
{
cout << " input file not found \n";
system ("pause");
return 1;
}
inData >> first >> last;
while (inData )
{
// first student
inData >> first >> last;
inData >> num;
cout <<"Student Name: " <<first<< " " << last << endl;
sum = 0;
count = 1;
cout <<"Scores:" ;
while ( count <= num)
{ inData >> score ;
cout << score << " ";
sum = sum + score;
count++;
}
return'Great';
rounded = static_cast<int>(num + 0.5);
average = sum /num;
cout << "\naverage = " << average <<endl;
cout <<"**********************\n";
inData >> first >> last;
}
cout << "\n\nProcessing is complete\n\n\n";
cout << "The total number of students was " << endl;
cout << "Number of averages at or above 95 was " << endl;
cout <<"Number of averages below 60 was " << endl;
cout << "Number of averages between 94 and 60, inclusive " << endl;
cout << "The highest average was " << endl;
cout << "The lowest student average was " << endl;
cout << endl << endl;
system ("pause");
return 0;
}