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

C++ Code An instructor at the university needs your help. He has a file with the

ID: 3667801 • Letter: C

Question

C++ Code An instructor at the university needs your help. He has a file with the students’ ID, assignments, exam1, exam2 and final exam. You need to implement a program to take this file and generate a new file with percentage score for each student after exam2 (consisting of the assignments, exam 1, and exam 2) for the instructor record in the middle of the semester, percentage score for each student after final exam, and the final grade of each student. Your file should output how many A’s and B’s in the class. You will use separate compilation where you will have 3 files (header file, implementation file and the main function) Development notes: 1- Define class TermGrade which will include different functions to get the percentage after exam 2, percentage after final exam, and the overall grade of each student. Also this class will define the variables needed in implementing the program. It will need the following methods: ReadData(istream& in). This reads the ID number and scores (one line of data) from the file. It returns true if the attempt to read data was successful, false otherwise. MidsemseterScore(). It returns the average of the assignments and first two exams. It returns a double. (Beware of integer division: 89/3 = 29; 89/3.0 = 29.66666667). This is a const method. FinalScore(). This returns the average of all grade components, as a double. This is a const method. LetterGrade(). This method returns ‘A’, ‘B’, ‘C’, ‘D’, or ‘F’ (character values). This is a const method. 2- Input data from grade1.txt and output data to finalgrade.txt. 3- Add menu to the instructor to choose (1- percent after exam 2, 2- percent after final exam, 3- all the above). 4- Assignments weight 20%, Exam1 weight 25%, Exam2 weight 25%, and Final exam weight 30%. 5- Calculate % after Exam 2 period, and after the final exam. 6- Include grade of students, grade depends on the final score percentage: - A: Final percentage greater than or equal 90 - B: Final percentage between 80 and 90. - C: Final percentage between 70 and 80. - D: For other percentages. Implementation details: Your program will have 3 source files: a header file and implementation file for the class, and a main program that #includes the class file and uses it. Use appropriate functional decomposition in your main program.

Explanation / Answer

#include "stdafx.h" #include #include #include #include #include using namespace std; struct StudentData { int studentID; string first_name; string last_name; int exam1; int exam2; int exam3; int total; char ch; }; const int SIZE = 9; const int INFO = 4; // Function prototypes void openInputFile(ifstream &, string); void getTotal(StudentData[]); void getGrade(StudentData[]); void calcLowest(StudentData[], int &, int &, int &, int &, int[]); void calcHighest(StudentData[], int &, int &, int &, int &, int[]); void getAverage(StudentData[], int, double &, double &, double &, double &, double[]); void getStd(StudentData[], double &, double &, double &, double &, double &, double &, double &, double &, double[]); void print(StudentData[], int[], int[], double[], double[]); void sort(StudentData[]); int main() { // Variables StudentData arr[SIZE]; int lowest1, lowest2, lowest3, lowest4; // Stores lowest exam scores int highest1, highest2, highest3, highest4; // Holds highest exam scores double average1 = 0, average2 = 0, average3 = 0, average4 = 0; // Represents average of each exam double std1 = 0, std2 = 0, std3 = 0, std4 = 0; // Holds standard deviation for Exams 1-3 and Total int lowest[INFO] = {}; int highest[INFO] = {}; double average[INFO] = {}; double standardDeviation[INFO] = {}; ifstream inFile; string inFileName = "C:\Users\Lisa\Desktop\scores.txt"; // Call function to read data in file openInputFile(inFile, inFileName); // Read data into an array of structs for(int count = 0; count > arr[count].studentID >> arr[count].first_name >> arr[count].last_name >> arr[count].exam1 >> arr[count].exam2 >> arr[count].exam3; } // Close input file inFile.close(); // Get score total for each student getTotal(arr); // Determine grade for each student getGrade(arr); // Calculate lowest scores in each exam and total scores calcLowest(arr, lowest1, lowest2, lowest3, lowest4, lowest); // Calculate highest scores in each exam and total scores calcHighest(arr, highest1, highest2, highest3, highest4, highest); // Calculate average of each exam and the average of the total scores getAverage(arr, SIZE, average1, average2, average3, average4, average); // Calculate standard deviation of each category getStd(arr, std1, std2, std3, std4, average1, average2, average3, average4, standardDeviation); cout