Do not use windows specific lib/headers Suppose we have a class class Person { p
ID: 3658529 • Letter: D
Question
Do not use windows specific lib/headers Suppose we have a class class Person { public: int id; vector scores; float averageScore; }; And we also have a vector of type person. Vectorv; In this vector we are going to store details of persons, the details will be read from a file. The file contains a space separated list of numbers. Each person takes 4 subjects so there will be a total of 4*n numbers in the file. Read all the numbers from the file and maintain a count of the numbers read. (your main FUNCTION should accept the name of the files as input). Divide the count by 4. That will give you the number of students whose data is being read in. Set up the vectorv according to the data that you just read in, id of the persons are 100, 110, 120, 130 So if the file has 100 numbers your vectorvwill have 25person information. Compute the average of the scores for each student and put it in averageScore Sort the vector according the average and print the id of the student with highest average.Explanation / Answer
#include #include #include #include using namespace std; class Person { public: int id; vector scores; float averageScore; }; void createtestfile(){//for testing purpose string datA="100 100 100 90 90 90 90 0 100 100 100 100 50 50 50 50"; ofstream make("testA.dat"); makeRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.