Question

C++ needs to output all of the name of the students not just first Write a...

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

Homework Answers

Answer #1

// 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

*/

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Java: A teacher has five students who have taken four tests. The teacher uses the following...
Java: A teacher has five students who have taken four tests. The teacher uses the following grading scale to assign a letter grade to a student, based on the average of his or her four test scores: Test Score Letter Grade 90–100 A 80–89 B 70–79 C 60–69 D 0–59 F Write a class that uses a String array (or an ArrayList object) to hold the five students’ names, an array of five characters to hold the five students’ letter...
Assignment #4 – Student Ranking : In this assignment you are going to write a program...
Assignment #4 – Student Ranking : In this assignment you are going to write a program that ask user number of students in a class and their names. Number of students are limited to 100 maximum. Then, it will ask for 3 test scores of each student. The program will calculate the average of test scores for each student and display with their names. Then, it will sort the averages in descending order and display the sorted list with students’...
Create a program to calculate and print basic stats on a set of a given input...
Create a program to calculate and print basic stats on a set of a given input values representing students' scores on an quiz. 1) Ask the user for the total number of quiz scores to be input (assume a positive integer will be given). 2) Create an array to hold all the quiz scores and then get all the scores from input to put into the array. For example, if the user input 10 in step (1) then you should...
write a program that automates the process of generating the final student report for DC faculty...
write a program that automates the process of generating the final student report for DC faculty considering the following restrictions. Consider declaring three arrays for processing the student data: studID studName studGrade The student ID is a random number generated by the 5-digit system in the range of (10000 - 99999). Create a function to assign the student ID generated in an array of numbers. Consider the following to generate the random number: Add the libraries: #include <stdlib.h> #include <ctime>...
You are to write a program that will process students and their grades. For each student...
You are to write a program that will process students and their grades. For each student the program will read in a student’s name. It should also read in 10 test scores for the student and calculate his or her average. You must read the scores using a loop. The program should output the student’s name, average and letter grade. The average should be displayed accurate to 1 decimal digit. Letter grades are assigned based on the scale: 90-100    A...
Teacher has given 5 exams which are all equally weighted to determine each student's final grade....
Teacher has given 5 exams which are all equally weighted to determine each student's final grade. The scores received so far by one student are: Exam 1 95 Exam 2 89 Exam 3 94 Exam 4 83 The above student's average is therefore a function for the grade received on the 5th exam. For the above average function, name the input and output variables. Complete the table below to numerically analyze this function. Exam 5 score Final Average 100 (95...
You are working for a company that is responsible for determining the winner of a prestigious...
You are working for a company that is responsible for determining the winner of a prestigious international event, Men’s Synchronized Swimming. Scoring is done by eleven (11) international judges. They each submit a score in the range from 0 to 100. The highest and lowest scores are not counted. The remaining nine (9) scores are averaged and the median value is also determined. The participating team with the highest average score wins. In case of a tie, the highest median...
Code in Java SAMPLE PROGRAM OUTPUT Because there are several different things your program might do...
Code in Java SAMPLE PROGRAM OUTPUT Because there are several different things your program might do depending upon what the user enters, please refer to the examples below to use to test your program. Run your final program one time for each scenario to make sure that you get the expected output. Be sure to format the output of your program so that it follows what is included in the examples. Remember, in all examples bold items are entered by...
6.12 LAB: Grade distribution In this lab, you will write a JavaScript program that generates a...
6.12 LAB: Grade distribution In this lab, you will write a JavaScript program that generates a bar graph of letter grades from a distributions of scores. Implement the parseScores function (1 point) Implement the parseScores function to take a space-separated string of scores as an argument and return an array of score strings. Each score is a number in the range [0, 100]. Ex: "45 78 98 83 86 99 90 59" → ["45","78","98","83","86","99","59"] Hint: JavaScript's string split() function can...
IN PSUEDOCODE PSUEDOCODE PSUEDOCODE PSUEDOCODE Write a program to calculate 10 students’ average test scores and...
IN PSUEDOCODE PSUEDOCODE PSUEDOCODE PSUEDOCODE Write a program to calculate 10 students’ average test scores and the grade. (You will ask the user to input all students and their grades). You may assume the following input data: Jack Johnson 85 83 77 91 76 Lisa Aniston 80 90 95 93 48 Andy Cooper 78 81 11 90 73 Ravi Gupta 92 83 30 69 87 Bonny Blair 23 45 96 38 59 Danny Clark 60 85 45 39 67 Samantha...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT