Write the app GPAScore that starts by obtaining a random type.lib.Student instan
ID: 3633475 • Letter: W
Question
Write the app GPAScore that starts by obtaining a random type.lib.Student instance using the getRandom method of that class. It then outputs some student data followed by a listing of all courses of a given that this student has taken. Here is a sample run:Enter the year ... 3
Student Name: FSLL
Student ID: 396578338
Student GPA: 2.3
---------------------------------------------------
364C C
3914 D
GPA in year 3 is: 2.5
---------------------------------------------------
In this run, the user is interested in third-year courses, i.e. ones whose numbers begin with "3". Note that the student GPA is formatted with one decimal. Note also that the listing is surrounded by two dashed lines (23 hyphens each). Each line in the listing contains a course number and the obtained grade in that course separated by a tab character. The listing is followed by the GPA of the student in the listed courses. You can assume, as a pre, that the user's input is an integer between 1 and 4, inclusive. If the student has not taken any course in the specified year, a message is displayed:
Enter the year ... 4
Student Name: QRPF
Student ID: 357633975
Student GPA: 2.3
--------------------------------------
No courses taken in year 4!
--------------------------------------
Use javac command to make sure the program complies.
Explanation / Answer
#include #include #include using namespace std; //Function Prototypes float gPACalculation(char cGrade); string honorsDistinction(float fGPA); void summaryInformation(float fGPA, string sHonorsDistinction); //Declare Constants const int SENTINEL = 0; int main () { //Declare Variables ifstream inFile; //input file ofstream outFile; //output file char cGrade =' '; //grades float fGPA = 0.0; //GPA int nTotalGradePoints = 0; //Total points int nCounter = 0; //counter string sHonorsDistinction = ""; //honors distinction string sStudentID = ""; //student id int nPointsEquivalent = 0; //equivalent points int nNumberOfGrades = 0; //number of grade inFile.open("StudentData.txt"); //open input file if (inFile) { outFile.open("SummaryStudentData.txt"); //open output file inFile >> sStudentID; inFile >> cGrade; //get grades from input file fGPA = gPACalculation (cGrade); //call GPA calculation function sHonorsDistinction = honorsDistinction(fGPA); //call HonorsDistinction function summaryInformation(fGPA, sHonorsDistinction); outFile.close(); //closes output file coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.