Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Write a program that reads students’ names followed by their test scores fro

ID: 3668586 • Letter: C

Question

C++ Write a program that reads students’ names followed by their test scores from the given input file. The program should output to a file, output.txt, each student’s name followed by the test scores and the relevant grade. Student data should be stored in a struct variable of type StudentType, which has four components: studentFName and studentLName of type string, testScore of type int and grade of type char. Suppose that the class has 20 students. Use an array of 20 components of type StudentType. Your program must contain at least the following functions: 1. A function to read the students’ data into an array. 2. A function to assign the relevant grade to each student. Your program should output each student’s name in this form: last name followed by a comma, followed by a space, followed by the first name; the name must be left justified. Moreover, other than declaring the variables and opening the input and output files, the function main should only be a collection of function calls.

Explanation / Answer

Run it with the file c: est.txt Hunter Stetsen 100 97 95 94 93 RJ Stetsen 97 97 93 94 90 Lisa Stetsen 97 93 97 93 92 Gerry Martin 97 95 92 93 94 John Dillow 92 93 93 94 93 Mary Dillow 95 94 97 93 92 Norm Johns 93 94 94 95 93 Lucy Johns 97 96 95 94 95 John Guinon 97 97 94 95 94 Haley Guinon 97 94 93 91 90 Justin Guinon 93 94 92 95 93 Jeff Gallows 93 97 97 93 92 Pam Royal 93 94 95 94 95 Curtis Hayes 92 93 94 95 93 Todd Clifton 93 94 93 92 91 John Fisher 93 97 97 94 97 Tammy Fae 97 97 94 93 92 Ingrid Pfister 97 93 97 94 91 Betty Soria 94 91 90 97 94 Indu Dornadula 95 94 92 90 90 // HERE IS THE PROGRAM U NEED #include // Standard Library Of Code For Main Functions. #include // Library Of Code For I/O Manipulations. #include // Library Of Code For Using Strings. #include // Library Of Code Used For Streaming Data Through Files. using namespace std; //Function For Reading Student's Data Into Array //Function For Assigning Grade //Function For Highest Test Score //Function For Displaying Name Of Student With Highest Test Score struct studentType //Structure for storing data { string studentFName[20];// First name string studentLName[20]; string studentData[20][3];//Lastname of student int testscore[20][5];//Testscore of student char grade[20];//Student's Grade }; // End of structure studentType s; int main() // Beginning of Main Functin { int index; int maxindex; int maxindex1; int coldex; int coldex1; int totalscore[20]; double avscore[20]; double highscore; double highindivscore; maxindex = 0; maxindex1 = 0; coldex1 = 0; ifstream infile;//Declaration of Output File infile.open("c:\test.txt"); //Opening of Input File for(index = 0; index < 20; index++) { infile >> s.studentFName[index] >> s.studentLName[index] >> s.testscore[index][0] >> s.testscore[index][1] >> s.testscore[index][2] >> s.testscore[index][3] >> s.testscore[index][4]; totalscore[index] = ((s.testscore[index][0]) + (s.testscore[index][1]) + (s.testscore[index][2]) + (s.testscore[index][3]) + (s.testscore[index][4])); avscore[index] = (static_cast(totalscore[index])/5); if(avscore[index]
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote