Hello Programmers!
I really need somebody's help, I am in an intro to C++ class and I am having a hard time getting my program to execute. I have to create a program that reads the first and last name, the first five integers as program scores, and the last 2 integers as test scores from an input text file. I also have to include error checks. I then need to take that information and output the program average, test average, course average, and letter grade. Many thanks in advance to anybody that can assist!
Data contained in the text file:
Jason Jones 77 87 76 82 92 96 90
Kathy Steinfield 67 77 87 88 86 89 96
Kevin Burnette 90 89 78 88 86 85 93
Josh Eley 92 87 88 89 90 91 78
Susie Lattimore 66 76 73 81 85 70 86
Stacey Smith 90 89 95 86 88 94 99
Aaron Nesmith 65 76 72 50 69 75 92
My Program thus far:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
#include<iostream>
#include<iomanip>
#include<fstream>
using namespace std;
int main (){
system("color f0");
ifstream fin;
ofstream fout;
fin.open("input3.txt");
fout.open("output3.txt");
if(!fin){
cout<<"Input failure\n";
system("pause");
return 1;
}
if(!fout){
cout<<"Output failure\n";
system("pause");
return 1;
}
string studentName;
int firstProgram, secondProgram, thirdProgram, fourthProgram, fifthProgram, firstTest, secondTest;
int programAverage, testAverage, courseAverage;
char courseGrade;
programAverage =static_cast<int>(firstProgram + secondProgram + thirdProgram + fourthProgram + fifthProgram)/(5);
testAverage =static_cast<int>(firstTest + secondTest)/(2);
courseAverage =static_cast<int>(programAverage + testAverage)/(2);
cout<<"Student Name"<<setw(10)<<"Program\nAverage"<<setw(10)<<"Test\nAverage"<<setw(10)<<"Course\nAverage"<<setw(10)<<"Letter\nGrade"<<setw(13)<<"Average\n"<<setw(10);
while(!fin.eof()){
fin>>studentName>>programAverage>>testAverage>>thirdProgram>>courseAverage>>courseGrade;
cout<<left<<fixed<<showpoint<<setprecision(2);
fout<<left<<fixed<<showpoint<<setprecision(2);
cout<<setw(10)<<studentName<<setw(10)<<programAverage<<setw(10)<<testAverage<<setw(10)<<courseAverage<<setw(10)<<endl;
fout<<setw(10)<<studentName<<setw(10)<<programAverage<<setw(10)<<testAverage<<setw(10)<<courseAverage<<setw(10)<<endl;
if(courseAverage>=90)courseGrade= 'A';
else if(courseAverage>=80)courseGrade= 'B';
else if(courseAverage>=70)courseGrade= 'C';
else if(courseAverage<=70)courseGrade= 'F';
}
fin.close();
fout.close();
system("pause");
return 0;
}//end of main
|
Student Name Program Test Course Letter
Average Average Average Grade
Jason Jones 82.80 93.00 87.90 B
Kathy Steinfield 81.00 92.50 86.75 B
Kevin Burnette 86.20 89.00 87.60 B
Josh Eley 89.20 84.50 86.85 B
Susie Lattimore 76.20 78.00 77.40 C
Stacey Smith 89.60 96.50 93.05 A
Aaron Nesmith 66.40 83.50 74.95 C
|