Question
or a class. There are 5 students in the class and each student has five grades during the tern. Name the program ClassGrades Write a
or a class. There are 5 students in the class and each student has five grades during the tern. Name the program ClassGrades
Write a type declaration that will store these grades and student names. Make sure grades are between 0 and 100.
Write a function LoadGrades() that ask the user for the five grades for each student and stores them in the array declared in (A).
Write a function DisplayGrades() that displays a table of the data n the array:
Write a function StuAvg() that displays a list of student averages similar to:
Write a function TestAve() that displays the averages on each test:
Write a menu-driver program that allows the user to select from the four functions above.
Below is an example of the program in action
Welcome to the Class Grade program. Choose from the following menu items: 1 - Load Grades 2 - Display Grades 3 - Display Student Average 4 - Display Test Average 1
Enter the student name and their 5 test grades. Enter name for student 1 _______________________________ Student Name: Bob Enter the five test scores 85 98 56 78 69 Enter name for student 2 _______________________________ Student Name: Mary Enter the five test scores 45 75 65 85 79 Enter name for student 3 _______________________________ Student Name: Sue Enter the five test scores 98 105 Score must be between 0 and 100. Please re-enter a score.100 85 96 97 Enter name for student 4 _______________________________ Student Name: Dave Enter the five test scores 65 45 68 72 187 Score must be between 0 and 100. Please re-enter a score.87 Enter name for student 5 _______________________________ Student Name: Bill Enter the five test scores 85 86 89 78 92 Welcome to the Class Grade program. Choose from the following menu items: 1 - Load Grades 2 - Display Grades 3 - Display Student Average 4 - Display Test Average 2
TEST STUDENT 1 2 3 4 5 Bob 85 98 56 78 69 Mary 45 75 65 85 79 Sue 98 100 85 96 97 Dave 65 45 68 72 87 Bill 85 86 89 78 92 Welcome to the Class Grade program. Choose from the following menu items: 1 - Load Grades 2 - Display Grades 3 - Display Student Average 4 - Display Test Average 3
STUDENT AVERAGE Bob 77.2 Mary 69.8 Sue 95.2 Dave 67.4 Bill 86 Welcome to the Class Grade program. Choose from the following menu items: 1 - Load Grades 2 - Display Grades 3 - Display Student Average 4 - Display Test Average 4
TEST AVERAGE 1 75.6 2 80.8 3 72.6 4 81.8 5 84.8 Welcome to the Class Grade program. Choose from the following menu items: 1 - Load Grades 2 - Display Grades 3 - Display Student Average 4 - Display Test Average
code i have:
#include
using namespace std;
struct Scores { string firstName = ""; int GPA = 0; };
int main() { Scores players[5]; for (int i = 1; i < 6; i++) { cout << "Enter info for player " << i << endl; cout << "_______________________________" << endl; cout << "Please enter the players first name: "; cin >> players[i].firstName; cout << "Please enter the players score: "; cin >> players[i].GPA; cout << endl; }
int choice = 0; string playerName = ""; int maxScore = 0;
while (true) { cout << "Press 1 to show the highest score for one player" << endl; cout << "Press 2 to show all scores for a particular player" << endl; cout << "Press 3 to show all scores for all players" << endl; cout << "Press 4 to show a list of players" << endl; cout << "Press 0 to exit the program." << endl;
cin >> choice;
if (choice == 1) { cout << "Please enter the player's name: "; cin >> playerName; for (int i = 0; i < 5; i++) { if (players[i].firstName == playerName) { if (players[i].GPA > maxScore) { maxScore = players[i].GPA; } } } cout << playerName << "'s Score: " << maxScore << endl; maxScore = 0; }else if (choice == 2) { cout << "Please enter the player's name: "; cin >> playerName; for (int i = 0; i < 5; i++) { if (players[i].firstName == playerName) { cout << players[i].firstName << " Score: " << players[i].GPA << endl; } } }else if (choice == 3) { for (int i = 0; i < 5; i++) { cout << "" << endl; cout << "Player " << i + 1 << ": " << players[i].firstName << " Score: " << players[i].GPA << endl; } }else if (choice == 4) { for (int i = 0; i < 5; i++) { cout << "" << endl; cout << "Player " << i+1 << ": " << players[i].firstName << endl; } }else if (choice == 0) { cout << "Good-Bye!" << endl; break; } } return 0; }
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