C++ needs to output all of the name of the students not just first Write a program which uses an array of string objects to hold the five students' full names (including spaces), an array of five characters to hold each student's letter grade, a multi-dimensional array of integers to hold each of the five student's four test scores, and an array of five doubles to hold each student's average test score. The program will use a function to allow the user to enter each student's name, and each student's four test scores, and store them in the appropriate arrays. The program will then use a second function to calculate each student's average test score and store it in the appropriate array, and determine each student's letter grade and store it in the appropriate array. Then in main, the program will display each student's name, average test score, and letter grade (averages to 3 decimal points). Validate that test scores are zero or greater, and 100 or less. You may use vectors instead of arrays, but built-in vector functions are limited to those in the textbook, pages 442-443.
Produce a screen print using the following data: -Edwin Allen Coe, test scores of 0, 75, 89, and 98 -Roger K. Mueller, test scores of 100, 93, 85, and 80 -Babbet Ruth, test scores of 50, 67, 81, and 100 -Rickey "Shuffle" Woods, test scores of 98, 96, 100, and 92 -Wynona Fudd, test scores of 83, 40, 87, and 88
// C++ code
#include <iostream>
#include <stdlib.h>
using namespace std;
void getInput(string name[], int marks[][4])
{
for(int i=0;i<5;i++){
cout<<"\nEnter student "<<i+1<<" name: ";
getline(cin,name[i]);
cout<<"Enter four subject marks: ";
for(int j=0;j<4;j++){
cin>>marks[i][j];
while(true)
{
if(marks[i][j] >= 0 && marks[i][j] <= 100)
break;
else
{
cout << "Invalid Input\nEnter again: ";
cin >> marks[i][j];
}
}
}
cin.ignore();
}
}
void avgAndGrade(double avg[], int marks[][4], char
grade[])
{
for(int i=0;i<5;i++)
{
int sum=0;
for(int j=0;j<4;j++){
sum=sum+marks[i][j];
}
avg[i]=sum/4.0;
if(avg[i]>90.0&&avg[i]<=100.0){
grade[i]='O';
}
else if(avg[i]>80.0&&avg[i]<=90.0){
grade[i]='A';
}
else if(avg[i]>70.0&&avg[i]<=80.0){
grade[i]='B';
}
else if(avg[i]>60.0&&avg[i]<=70.0){
grade[i]='C';
}
else if(avg[i]>50.0&&avg[i]<=60.0){
grade[i]='D';
}
else if(avg[i]<=50.0){
grade[i]='F';
}
}
}
int main()
{
string name[5];
char grade[5];
double avg[5];
int marks[5][4];
getInput(name,marks);
avgAndGrade(avg, marks, grade);
for(int i=0;i<5;i++)
{
cout<<"\n\nName :"<<name[i];
cout<<"\nAverage : "<<avg[i];
cout<<"\nGrade : "<<grade[i];
}
return 0;
}
/*
output:
Enter student 1 name: Edwin Allen Coe
Enter four subject marks: 0 75 89 98
Enter student 2 name: Roger K. Mueller
Enter four subject marks: 100 93 85 80
Enter student 3 name: Babbet Ruth
Enter four subject marks: 50 67 81 100
Enter student 4 name: Rickey "Shuffle" Woods
Enter four subject marks: 98 96 100 92
Enter student 5 name: Wynona Fudd
Enter four subject marks: 83 40 87 88
Name :Edwin Allen Coe
Average : 65.5
Grade : C
Name :Roger K. Mueller
Average : 89.5
Grade : A
Name :Babbet Ruth
Average : 74.5
Grade : B
Name :Rickey "Shuffle" Woods
Average : 96.5
Grade : O
Name :Wynona Fudd
Average : 74.5
Grade : B
*/
Get Answers For Free
Most questions answered within 1 hours.