subject

Write a C++ program that will ask the user for the name of a data file. This data file contains a list of students in some class.
The names are listed, one per line, in the following format:
lastName firstName middleInitial
and each part of the name is separated by a space.
Each student in this class has a data file that contains an unknown number of test scores. The name of each student’s data file is formed by concatenating the students first and last name and adding ".dat", for example:
Student Name: Tuel Dennis D
Student Data File: DennisTuel. dat
Your program should open each student’s data file, read in the scores and calculate the student’s average.
In addition to calculating the average for each student you should report the average for the class, and the highest and lowest test score in the class.
Note: All averages should be rounded to the nearest hundredth.
cout << fixed << setprecision(2);
Example:Data File: Students. dat
Tuel Dennis DDrummond Ann MMaxwell Virginia L
DennisTuel. dat
85
88
92
86
AnnDrummond. dat
95
72
88
89
VirginiaMaxwell. dat
68
75
83
98
Sample Program Output:
Enter Name of Data File: Students. dat
Students Average
Dennis D Tuel 87.75
Ann M Drummond 86.00
Virginia L Maxwell 81.00
Class Average: 84.92
Max Score: 98.00
Min Score 68.00
This is my answer, but its not correct. How to fix it.
#include
#include
#include
#include
#include
using namespace std;
int main(){
string name[3];
int tmpScore, studentTotal, minScore, maxScore, countStudent, countClass;
ifstream studentDat;
ifstream namelist;
double classTotal;
minScore = 100;
maxScore = 0;
classTotal = 0.0;
countClass = 0;
cout << setw(20) << left << "students";
cout << setw(5) << left << "Data" << endl;
while(!namelist. eof()){
for(int i=0;i<3;i++){
namelist >> name[i];
}
studentDat. open((name[1]+name[0]+".dat").c_str ());
studentTotal = countStudent = 0;
while(!studentDat. eof()){
studentDat >> tmpScore;
if(tmpScore>maxScore){
maxScore = tmpScore;
}
if(tmpScore>maxScore){
minScore = tmpScore;
}
studentTotal += tmpScore;
countStudent ++;
}
studentDat. close();
classTotal += (double)studentTotal / (double)countStudent;
countClass++;
cout< < < < cout< <<(double)studentTotal/(doubl e)countStudent
< }
cout << setw(20)< cout << (double)classTotal/(double)countCla ss
< cout << setw(20) << left << "Max Score:";
cout << (double)maxScore << endl;
cout << setw(20) << left << "min Score:";
cout << (double)minScore << endl;
namelist. close();
return 0;
}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 20:30
What is the biggest difference between section breaks and regular page breaks
Answers: 1
question
Computers and Technology, 24.06.2019 20:00
Write c++programs for the following problem: let the user enter two numbers and display which is greater. !
Answers: 1
question
Computers and Technology, 24.06.2019 22:00
Iam trying to get my google account back for school and business, can someone ?
Answers: 1
question
Computers and Technology, 25.06.2019 05:30
When a game allows you to pick party members from a large pool, each with different classes and roles but in which no single party combination is clearly superior to others, the game is using: intransitive relationships transitive relationships orthogonal relationships parallel relationships
Answers: 1
You know the right answer?
Write a C++ program that will ask the user for the name of a data file. This data file contains a l...
Questions
Questions on the website: 13722362