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, 22.06.2019 19:00
Stacy works as blank. the most important soft skill she needs for this role is blank.
Answers: 3
question
Computers and Technology, 23.06.2019 05:00
Which best explains why a digital leader would join a society specializing in technology
Answers: 1
question
Computers and Technology, 24.06.2019 05:30
Why is hard disk space important to an audio engineer? why are usb ports and firewire ports useful for an audio engineer? explain in 2-3 sentences. (3.0 points) here's a list of different audio software: ableton live apple inc.'s garageband apple inc.'s logic studio digidesign's pro tools propellerhead sofware's reason sony creative software's acid pro steinberg cubase steinberg nuendo choose one of the software programs listed above, and then go to that software program's web site. read about what the software program is used for, and then write 4-5 sentences about what you learned. (10.0 points) which type of software license is the most limiting? why? explain in 2-3 sentences. (3.0 points) when sending a midi channel voice message, how can you control the volume of the sound? explain in 2-3 sentences. (4.0 points)
Answers: 1
question
Computers and Technology, 24.06.2019 17:50
You will subnet the network address 172.31.103.0/24. the network has the following requirements: · room-114 lan will require 27 host ip addresses · room-279 lan will require 25 host ip addresses · room-312 lan will require 14 host ip addresses · room-407 lan will require 8 host ip addresses how many subnets are needed in the network topology?
Answers: 2
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
question
Social Studies, 11.01.2021 22:50
question
Geography, 11.01.2021 22:50
Questions on the website: 13722362