Question

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 (but under 90), a C if weighted average is at least 70 (but under 80), a D if weighted average is at least 60 (but under 70), or an F if weighted average is under 60. You should use a nested if-else-if to determine the grade.

You are asked to write a program to get a student’s ID and exam scores, and displays student ID, weighted average and letter grade. The program should keep on running as long as student ID entered is not -1.

Here is a run-time example:

Enter student’s ID: A123

Enter student’s four exam scores, separate each by a space: 56 87 92 86

The weighted average for student A123 is 82.6, letter grade is B.

Enter student ID: -1

Good Bye.

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

#include <iostream>
#include<string>
using namespace std;

int main()
{
string studentId;
int scores[4];//array to store the scores of the exams
int max_score,total;
float weighted_avg;
char grade;
cout<<"Enter student ID: ";
cin>>studentId;
//loop runs as long as the student ID is not -1
while(studentId.compare("-1")){
cout<<"Enter student’s four exam scores, separate each by a space: ";
for(int i=0;i<4;i++){
cin>>scores[i];
}
max_score=0;
//to calculate the maximum score among four exams
for(int i=0;i<4;i++){
if(scores[i]>max_score){
max_score=scores[i];
}
}
//to calculate total sum of scores plus maximum score
total=max_score;
for(int i=0;i<4;i++){
total=total+scores[i];
}
//to calculate weighted average
weighted_avg=total/5;
//to assign a grade
if(weighted_avg>=90){
grade='A';
}
else if(weighted_avg>=80 && weighted_avg<90){
grade='B';
}
else if(weighted_avg>=70 && weighted_avg<80){
grade='C';
}
else if(weighted_avg>=60 && weighted_avg<70){
grade='D';
}
else if(weighted_avg<60){
grade='F';
}
cout<<"The weighted average for student "<<studentId<<" is "<<weighted_avg<<", letter grade is "<<grade<<"."<<endl;
cout<<"Enter student ID: ";
cin>>studentId;
}
cout<<"Good Bye."<<endl;
return 0;
}

Add a comment
Answer #2

I have implemented the code as required.Please find the code and the screenshot below.

Code:

#include <iostream>

#include <string>

using namespace std;

int main() {

    int num[4];         // array to store all the scores

    string id = "";     // store id

    int max = -1;       // variable to count max_score

    int sum = 0;        // variable to calculate total

    string grade;       // variable to store grades

    float avg;          // variable to store weighted average

    while(true){        // loop infintely

        cout << "Enter student’s ID: ";     

      cin >> id;

        if (id == "-1"){        // if user enters -1 as id, exit from the loop

            break;

        }

        cout << "Enter student’s four exam scores, separate each by a space: ";

        cin >> num[0] >> num[1]>> num[2]>> num[3];

        for (int i = 0;i<4;i++){

            if (num[i]>max){

                max = num[i];       // calculate highest score

            }

            sum += num[i];

        }

        sum += max;

        avg = float(sum)/5;         // get weighted 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{

            grade = 'F';

        }

    cout << "The weighted average for student "<<id<<" is "<<avg<<" letter grade is "<<grade<<endl;

    }

    cout <<"Good Bye.";

return 0;

}


Screenshot:

media%2F6cb%2F6cbc6cb0-77c8-4714-b6df-36

32 grade B else if (avg>-70) grade - C 34 35 37 else if (avg>-60) grade D 40 else grade - F 43 cout << The weighted average

Output

https://StudentWeightedScore.sayandip 199309.repl.run clang version 7.0.0-3ubuntu0.18.04.1 (tags/RELEASE_700/final) Enter stu

Add a comment
Know the answer?
Add Answer to:
C ++ . In professor Maximillian’s course, each student takes four exams. A student’s letter grade...
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
  • Use your knowledge of algorithm development to create a program using RAPTOR to solve the problem...

    Use your knowledge of algorithm development to create a program using RAPTOR to solve the problem below. Input a list of student names (in to array student[]) and testing scores stored in parallel arrays. Each student have 3 testing scores ranging from 0 to 100 (store into parallel array score1[], score2[], score3[]). Output average score for each student and print out what is his final grade. If average score <60, got F grade. If 60<=average score<70, got D grade. If...

  • 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...

  • Java Program: In this project, you will write a program called GradeCalculator that will calculate the...

    Java Program: In this project, you will write a program called GradeCalculator that will calculate the grading statistics of a desired number of students. Your program should start out by prompting the user to enter the number of students in the classroom and the number of exam scores. Your program then prompts for each student’s name and the scores for each exam. The exam scores should be entered as a sequence of numbers separated by blank space. Your program will...

  • Develop an interactive program to assist a Philosophy professor in reporting students’ grades for his PHIL-224.N1...

    Develop an interactive program to assist a Philosophy professor in reporting students’ grades for his PHIL-224.N1 to the Office of Registrar at the end of the semester. Display an introductory paragraph for the user then prompt the user to enter a student record (student ID number and five exam-scores – all on one line). The scores will be in the range of 0-100. The sentinel value of -1 will be used to mark the end of data. The instructor has...

  • Write a c++ program to compute and print the grade for one student. The grade is...

    Write a c++ program to compute and print the grade for one student. The grade is based on three mid-term exams (worth a possible 25 points each) of which the best two are only considered in the computation, two quizzes (5 points each), and a 40 points final exam. Your output should include all scores (2 best midterms, 2 quizzes and the final exam), the percentage grade, and the letter grade. Solve it using nested if. The grading scale is:...

  • In C Langage Write a grading program for a class with the following grading policies:- a. There are two quizzes, each gr...

    In C Langage Write a grading program for a class with the following grading policies:- a. There are two quizzes, each graded on the basis of 10 points. b. There is one midterm exam and one final exam, each graded on the basis of 100 points. c. The final exam counts for 50 percent of the grade, the midterm counts for 25 percent and the two quizzes together count for a total of 25 percent. Grading system is as follows:-...

  • Set up four different algorithms and flowcharts for calculating a student’s letter grade given the following...

    Set up four different algorithms and flowcharts for calculating a student’s letter grade given the following (do not use straight-through logic): 90-100 = A 80-89 = B 70-79 = C 60-69 = D below 60 = F Which of the four solutions would be the best? Justify your answer.

  • Write a grading program in Java for a class with the following grading policies: There are...

    Write a grading program in Java for a class with the following grading policies: There are three quizzes, each graded on the basis of 10 points. There is one midterm exam, graded on the basis of 100 points. There is one final exam, graded on the basis of 100 points. The final exam counts for 40% of the grade. The midterm counts for 35% of the grade. The three quizzes together count for a total of 25% of the grade....

  • Many classes calculate a final grade by using a weighted scoring system. For example, “Assignments” might...

    Many classes calculate a final grade by using a weighted scoring system. For example, “Assignments” might be worth 40% of your final grade. To calculate the grade for the Assignments category, the teacher takes the percentage earned on the assignments and multiplies it by the weight. So if the student earned a 90% total on the Assignments, the teacher would take 90% x 40, which means the student earned a 36 percent on the Assignments section. The teacher then calculates...

  • c++ implement a student class Determine the final scores, letter grades, and rankings of all students...

    c++ implement a student class Determine the final scores, letter grades, and rankings of all students in a course. All records of the course will be stored in an input file, and a record of each student will include the first name, id, five quiz scores, two exam scores, and one final exam score. For this project, you will develop a program named cpp to determine the final scores, letter grades, and rankings of all students in a course. All...

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