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

Please write a C++ program in Visual Studio. Instructions Write a program that r

ID: 3698839 • Letter: P

Question

Please write a C++ program in Visual Studio.

Instructions Write a program that reads students' names followed by their test scores. The program should output each student's name followed by the test scores and the relevant grade. It should also find and print the highest test score and the name of the students having the highest test score. Student data should be stored in a struct variable of type studentType , which has four components: studentFNane and studentLName of type string, testScore of type int (testScore is between 0 and 100), 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: .A function to read the students' data into the array. A function to assign the relevant grade to each student. A function to find the highest test score. A function to print the names of the students having the highest test score. Your program must output each student's name in this form: last name followed by a comma, followed bya 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 Your program should accept no input and save the output to Ch9 Ex2Out.txt.

Explanation / Answer

Please find my implementation:

//header files

#include <iostream>

#include <iomanip>

#include <string>

using namespace std;

//structure definition

struct studentType

{

     string fName, lName;

     int Scores;

     char grade;/*this is optional if you want grade you can put other wise no need*/

};

//declaring structure

studentType students[20];

//main function

int main ()

{

     int n;//for number of students

     int heighest=0;

     //reading size

     cout<<"Enter number of studetns(max 20) "<<endl;

     cin >>n;

     //asking for details

     cout<<"Enter student details (first name, last name, score)"<<endl;

     int x=0;

     //reading details

     while(x<n)

     {

          //reading student iformation

          cin>>students[x].fName>>students[x].lName>>students[x].Scores;

          /* if you want to find grade remove following comments*/

          /*if(students[x].Scores >= 90)

          students[x].grade = 'A';

          else if(students[x].Scores >= 80)

          students[x].grade = 'B';

          else if(students[x].Scores >= 70)

          students[x].grade = 'C';

          else if(students[x].Scores >= 60)

          students[x].grade = 'D';

          else

          students[x].grade = 'F';*/

          //finding heighest score

          if(heighest<students[x].Scores)

              heighest=students[x].Scores;

          x++;

     }

     //Displaying heighest score and names

     cout<<"Heighest core is :"<<heighest<<endl;

     cout<<"Stundents with heighest score is :"<<endl;

     for(x=0;x<n;x++)

     {

          if(students[x].Scores==heighest)

              cout<<students[x].lName<<" "<<students[x].fName<<endl;

     }

     //displaying entire information

     cout<<"All students information"<<endl;

     for(x=0;x<n;x++)

     {

          cout.setf(ios::right);

          cout<<students[x].lName<<","<<students[x].fName<<" "<<students[x].Scores<<endl;

     }

     system("pause");

     return 0;

}//end of main