Question
Use C++ to write a program that will read in a list of names for students along with the students grades. Then based on the
Use C++ to write a program that will read in a list of names for students along with the students grades. Then based on the users selection from a menu, you will output a table of student names with either their average, maximum, or minimum numerical grade along with the corresponding letter grade. Sample output is provided at the end of this document.
The program should do the following:
. Load the names of students into an array and their grades into another array from a file. The arrays should be parallel arrays. The file used will be called NamesGrades.txt and will be provided to you.
. Continuously present a menu to the user given him/her the options of average, maximum, minimum, or quit. If the user chooses to quit, the program should end otherwise the presentation of the menu should continue.
. Display a table of appropriate grades based on the users selection
You will be provided with a starter file called PA3_starter.cpp. This file has the framework of the program. You will need to write in the code for main and all the functions. You may add more functions if you feel that you need them, however do not remove any of the provided functions. Do not change the headers of the functions that are provided.
Make sure you use good programming style. This includes commenting all your variables and commenting through your code. Comments should explain why you are doing something. Use good indentation. Make sure variable names are self-documenting. Make good use of white space. You should group logical sections together with one blank line between logical sections.
The output should be neat and pleasant to read.
Make sure to follow the specifications. If you must, you can add to the program, but do not change the specifications in doing so.
PA3_starter.cpp File: // Headers #include// cout, cin #include // exit() #include // strings #include // file processing #include // stream manipulation using namespace std; // Global variables const int MAX_STUDENTS = 25; // We will not process more than 25 students even if the file contains more const int MAX_GRADES = 5; // Each student has exactly 5 grades const string FILENAME = "NamesGrades.txt"; // The name of the file that you will read // Function declarations int loadStudentNamesGrades(string students[], int grades[][MAX_GRADES], string fileName, int maxStudents); void displayAverages(string students[], int grades[][MAX_GRADES], int studentCount); void displayMax(string students[], int grades[][MAX_GRADES], int studentCount); void displayMin(string students[], int grades[][MAX_GRADES], int studentCount); char getLetterGrade(double grade); int getLongestNameLength(string students[], int studentCount); int main() { // You will need some variables here // You need one to keep up with the actual number of students // You need an array of strings for the student names // You need a two dimensional array of ints for the grades of the students // You need a variable to hold the choice of the user for the menu // Get students and grades // Loop until user says to quit // present menu and get user's choice // Process the choice // End of program // Make sure we place the end message on a new line cout << endl; return 0; } /*********************************************************** loadStudentNameGrades opens and read fileName. It will read in two strings, concatenate them, and then save to the students array. It then reads five integers and save each to the grades array. The function will return the actual number of student/grade combinations read PARAM: students is an array of strings that can hold up ot maxStudents values grades is a two dimensional array for holding the grades of each student fileName is the name of the file that will be opened and read maxStudents is the maximum number of students that we will read from the file PRE: students[] is large enough to contain up to maxStudents elements grades[] is large enough ot contain up to maxStudents elements POST: students[] contains the names of up to maxStudents grades[][] contains the grades for up to maxStudents The number of student/grade combinations actually read from the file is returned. This value can range between 0 <= numStudents <= maxStudents NOTE: students[] and grades[] are meant to be parralel arrays. students[0] and grades[0] are the same student ************************************************************/ int loadStudentNamesGrades(string students[], int grades[][MAX_GRADES], string fileName, int maxStudents) { return 0; // for stub out purposes, change this in your code } /*********************************************************** displayAverages calculates the average of each student and displays the students name, average, and letter grade of the average in a table PARAM: students[] is an array of strings that contains the names of studentCount students grades[] is an array of integers that contains the grades of studentCount students studentCount contains the value of the number of elements in the students[] and grades[] arrays PRE: students[] and grades[] contain values for studentCount elements POST: table of student names, averages, and letter grades is displayed ************************************************************/ void displayAverages(string students[], int grades[][MAX_GRADES], int studentCount) { } /*********************************************************** displayMax calculates the maximum grade of each student and displays the students name, maximum grade, and letter grade of the maximum grade in a table PARAM: students[] is an array of strings that contains the names of studentCount students grades[] is an array of integers that contains the grades of studentCount students studentCount contains the value of the number of elements in the students[] and grades[] arrays PRE: students[] and grades[] contain values for studentCount elements POST: table of student names, maximum grades, and letter grades is displayed ************************************************************/ void displayMax(string students[], int grades[][MAX_GRADES], int studentCount) { } /*********************************************************** displayMin calculates the minimum grade of each student and displays the students name, minimum grade, and letter grade of the minimum grade in a table PARAM: students[] is an array of strings that contains the names of studentCount students grades[] is an array of integers that contains the grades of studentCount students studentCount contains the value of the number of elements in the students[] and grades[] arrays PRE: students[] and grades[] contain values for studentCount elements POST: table of student names, minimum grades, and letter grades is displayed ************************************************************/ void displayMin(string students[], int grades[][MAX_GRADES], int studentCount) { } /*********************************************************** getLetterGrade converts a numerical grade to a letter grade PARAM: grade is the numerical grade to convert. Expected range is 0 <= grade <= 100 PRE: grade contains a value in the correct range POST: The corresponding letter grade of the numerical grade is returned ************************************************************/ char getLetterGrade(double grade) { } /*********************************************************** getLongestNameLength returns the length of the longest string from a list of strings PARAM: students[] is an array of strings that contains the name of students studentCount is the size of the students[] array PRE: students[] contains studentCount names POST: The length of the longest string in students[] is returned ************************************************************/ int getLongestNameLength(string students[], int studentCount) { }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started