Question

in C++ Create a program that will calculate a student’s grade average of 5 test scores...

in C++

Create a program that will calculate a student’s grade average of 5 test scores and assign a letter grade for a student. The program should use a class to store the student’s data including the student’s name and score on each of 5 tests. The program should include member functions to 1) get the student’s test scores, 2) calculate the average of the test scores, and 3) display the results as follows:

Test scores for Mary:

100

90

75

80

98

The average of the scores is 88

Mary’s grade is B

in C++
0 0
Add a comment Improve this question Transcribed image text
Answer #1

/* Below is your required code */

#include <iostream>
#include<string>
using namespace std;
class student{
public:
string name;
int marks[5];
float avg=0;
void get(){
cout<<"Enter name of student = ";
cin>>name;
for(int i=0;i<5;i++){
cout<<"Enter marks in "<<i+1<<"th subject : ";
cin>>marks[i];
}
}
void getaverage(){
  
for(int i=0;i<5;i++){
avg+=marks[i];
}
avg/=5;
}
void display(){
cout<<"Test scores for "<<name;
for(int i=0;i<5;i++)
cout<<endl<<marks[i];
char grade;
cout<<"\nThe average of the scores is "<<avg;
if(avg>=90) grade='A';
else if(avg>=80) grade='B';
else if(avg>=70) grade='C';
else if(avg>=60) grade='D';
else if(avg>=50) grade='E';
else
grade='F';
cout<<endl<<name<<"'s grade is "<<grade;

}


};
int main()
{
student s;
s.get();
s.getaverage();
s.display();

return 0;
}

Add a comment
Know the answer?
Add Answer to:
in C++ Create a program that will calculate a student’s grade average of 5 test scores...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a C++ program to calculate grades as well as descriptive statistics for a set of...

    Create a C++ program to calculate grades as well as descriptive statistics for a set of test scores. The test scores can be entered via a user prompt or through an external file. For each student, you need to provide a student name (string) and a test score (float). The program will do the followings: Assign a grade (A, B, C, D, or F) based on a student’s test score. Display the grade roster as shown below: Name      Test Score    ...

  • C++: Create a grade book program that includes a class of up to 20 students each...

    C++: Create a grade book program that includes a class of up to 20 students each with 5 test grades (4 tests plus a Final). The sample gradebook input file (CSCI1306.txt) is attached. The students’ grades should be kept in an array. Once all students and their test scores are read in, calculate each student’s average (4 tests plus Final counts double) and letter grade for the class. The output of this program is a tabular grade report that is...

  • Write a program that will calculate each student’s average score over several tests. The program will...

    Write a program that will calculate each student’s average score over several tests. The program will ask for the number of students, and the number of scores per student. Then, for each student, it will ask for all test results and display the average. The output should look similar to what is shown below (sample user input is shown in bold) ( write by python and Screenshot it for me , thank) How many students do you have? 3 How...

  • Write a complete C++ program that reads students names and their test scores from an input...

    Write a complete C++ program that reads students names and their test scores from an input text file. The program should output each student’s name followed by the test scores and the relevant grade in an output text file. It should also find and display on screen the highest/lowest test score and the name of the students having the highest/lowest test score, average and variance of all test scores. Student data obtained from the input text file should be stored...

  • [JAVA/chapter 7] Assignment: Write a program to process scores for a set of students. Arrays and...

    [JAVA/chapter 7] Assignment: Write a program to process scores for a set of students. Arrays and methods must be used for this program. Process: •Read the number of students in a class. Make sure that the user enters 1 or more students. •Create an array with the number of students entered by the user. •Then, read the name and the test score for each student. •Calculate the best or highest score. •Then, Calculate letter grades based on the following criteria:...

  • c++ Instructions Overview In this programming challenge you will create a program to handle student test...

    c++ Instructions Overview In this programming challenge you will create a program to handle student test scores.  You will have three tasks to complete in this challenge. Instructions Task 1 Write a program that allocates an array large enough to hold 5 student test scores. Once all the scores are entered, the array should be passed to a function that sorts them in ascending order. Another function should be called that calculates the average score. The program should display the...

  • C ++ . In professor Maximillian’s course, each student takes four exams. A student’s letter grade...

    C ++ . In professor Maximillian’s course, each student takes four exams. A student’s letter grade is determined by first calculating her weighted average as follows:                                                 (score1 + score2 + score3 + score4 + max_score) weighted_average = -----------------------------------------------------------------------                                                                                                 5 This counts her maximum score twice as much as each of the other scores. Her letter grade is then a A if weighted average is at least 90, a B if weighted average is at least 80...

  • Write a c++ program which uses a structure having the indicated member names to store the...

    Write a c++ program which uses a structure having the indicated member names to store the following data: Name (student name) IDnum (student ID number) Tests (an array of three test scores) Average (average test score) Grade (course grade) The program will keep a list of three test scores for one student. The program may prompt the user for the name, ID number, and test scores, or these may be assigned within the program. The average test score will be...

  • Create a C++ program to : Prompt user for seven test score Store the scores into...

    Create a C++ program to : Prompt user for seven test score Store the scores into an array Print the array before and after sorting Print the test average Convert the average to letter grade Search for a test score 90, using linear search Print, if test score 90 was found and at what position Add Comments SEPARATE THE FILES INTO 3 : header.h, functions.cpp, main.cpp

  • Write a program that asks the user to enter five test scores. The program should display...

    Write a program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Design the following functions in the program: calcAverage—This function should accept five test scores as arguments and return the average of the scores. determineGrade—This function should accept a test score as an argument and return a letter grade for the score (as a String), based on the following grading scale: Score Letter Grade...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT