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 08:10
Ihave a music player on my phone. i can buy songs, add them to playlists and play them. obviously it would be redundant to store each song in each playlist; each playlist is just a list of pointers to the songs. for this lab you will simulate this behavior. your program will need to have options to: add songs to the system library (you will store the text of the first line of the song, rather than the audio) add playlists add songs to a playlist list playlists play a playlist list all of the songs in the library with a count of how many times each song has been played remove a song from a playlist remove a playlist remove a song from the library (and thus from all playlists that contain it) note that we will not be checking many error cases. in real programming this would be bad, you should usually try to recognize and respond to as many types of errors as you can. in the context of class we are trying to acquaint you with as many concepts as possible, so for the sake of educational efficiency we will not be checking most errors in this lab, you may assume that your user provides correct input. you may add all appropriate error testing if you wish, but we will not be testing for it.
Answers: 2
question
Computers and Technology, 22.06.2019 21:30
Im doing this last minute and literally none of my neighbors or people that my dad works with use excel so if anyone could me make up an example
Answers: 1
question
Computers and Technology, 22.06.2019 22:10
Asequential circuit contains a register of four flip-flops. initially a binary number n (0000 ≤ n ≤ 1100) is stored in the flip-flops. after a single clock pulse is applied to the circuit, the register should contain n + 0011. in other words, the function of the sequential circuit is to add 3 to the contents of a 4-bit register. design and implement this circuit using j-k flip-flops.
Answers: 1
question
Computers and Technology, 23.06.2019 04:31
Q14 what is most important for you to choose before you build a network? a. private network b. nos c. network media d. network protocol e. directory service
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
question
Mathematics, 11.10.2021 22:50
question
Chemistry, 11.10.2021 22:50
question
Mathematics, 11.10.2021 22:50
Questions on the website: 13722361