ABSOLUTE C++ -TEXT
ABSOLUTE C++ -TEXT
6th Edition
ISBN: 2810017515514
Author: SAVITCH
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 6, Problem 1PP

Write a grading program for a class with the following grading policies:

  1. There are two quizzes, each graded on the basis of 10 points.
  2. There is one midterm exam and one final exam, each graded on the basis of 100 points.
  3. The final exam counts for 50 % of the grade, the midterm counts for 25 % , and the two quizzes together count for a total of 25 % . (Do not forget to normalize the quiz scores. They should be converted to a percentage before they are aver-aged in.)

Any grade of 90 or more is an A, any grade of 80 or more (but less than 90) is a B, any grade of 70 or more (but less than 80) is a C, any grade of 60 or more (but less than 70) is a D, and any grade below 60 is an F. The program will read in the student’s scores and output the student’s record, which consists of two quiz and two exam scores as well as the student’s average numeric score for the entire course and final letter grade. Define and use a structure for the student record.

Expert Solution & Answer
Check Mark
Program Plan Intro

Program Plan:

1. The following variables are used in the program.

  • quiz1 variable of integer data type is used to store the score of quiz 1.
  • quiz2variable of integer data type is used to store the score of quiz 2.
  • midtermvariable of integer data type is used to store the score of midterm exam.
  • final variable of integer data type is used to store the score of final exam.
  • grade variable to character data type is used to store the final grade.
  • Student struct to store all the scores of the student.

2. The following method is used in the program:

calculate() method to calculate the final score of the student.

Program Description:

In this program, user input is taken for all the 4 scores. These scores are used to calculate the final score. The final grade is decided based on the final score. The scores of a student are stored in a struct.

Explanation of Solution

#include <iostream>

using namespace std;

// structure to hold scores of a student 
struct Student
{
    int quiz1, quiz2;
    int midterm, final;
};

// method to calculate the final score of a student 
// takes the structure as a parameter
float calculate(Student& s)
{
    int quiz;
    float total;

    quiz = s.quiz1 + s.quiz2;

    total = (s.final/2) + (s.midterm/4) + (quiz/4)*5;

    return total;
}


// main method for testing of the code 
int main()
{
    // variable of type struct created
    Student s;

    // user input taken for all 4 scores 
    std::cout << "Enter the score of quiz 1: ";
    std::cin >> s.quiz1;

    std::cout << "Enter the score of quiz 2: ";
    std::cin >> s.quiz2;

    std::cout << "Enter the score of midterm exam: ";
    std::cin >> s.midterm;

    std::cout << "Enter the score of final exam: ";
    std::cin >> s.final;

    // final score collected from calculate() method
    float a = calculate(s);
    char grade;

    // calculating grade based on final score 
    if(a>=90)
        grade = 'A';
    if(a<90 && a>=80)
        grade = 'B';
    if(a<80 && a>=70)
        grade = 'C';
    if(a<70 && a>=60)
        grade = 'D';
    if(a<60)
        grade = 'F';

    // displaying student result  
    std::cout << "\n=== STUDENT RECORD ===" << std::endl;
    std::cout << "Quiz 1: " << s.quiz1 << std::endl;
    std::cout << "Quiz 2: " << s.quiz2 << std::endl;
    std::cout << "Midterm exam: " << s.midterm << std::endl;
    std::cout << "Final exam: " << s.final << std::endl;
    std::cout << "Average score: " << a << std::endl;
    std::cout << "Final grade: " <<grade << std::endl;

    return 0;
}

Sample output:

Enter the score of quiz 1: 6
Enter the score of quiz 2: 5
Enter the score of midterm exam: 60
Enter the score of final exam: 75

=== STUDENT RECORD ===
Quiz 1: 6
Quiz 2: 5
Midterm exam: 60
Final exam: 75
Average score: 62
Final grade: D

Explanation:

In the above program, a struct is created having 4 integer data members to store all the 4 scores. In the main() function, user input is taken for all the 4 scores. These scores are stored in the struct data members. The struct is passed as a parameter to the calculate() function. The calculate() function calculates the final score and returns the final score. The final score is collected from the calculate() function inside main() function. Using multiple if statements, the final grade is decided based on the final score. The 4 scores along with the final score and the final grade of the student are displayed.

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
Description: In a hypothetical class, students take two midterms and an optional final. If a student takes the final and gets in it a better score than the lowest of the two midterm scores, then the lowest midterm score would be replaced by the comprehensive final score. The overall score will then be calculated by averaging the three test scores. If the student does not take the optional final, the overall score is calculated using only the two midterm scores. Students' exam scores are included in the "Question1" tab in the attached worksheet. Empty data entries for the optional comprehensive final means that the student did not take the optional final. Tasks: Task 1: In Question1 _Module, code a function that requires midterm1 score, midterm2 score, and comprehensive final as inputs and calculate the overall score per the description above. Task 2: In Question1_Module, code a Sub that uses the function coded in task 1 to fill column 'I' of the worksheet and link this sub to the…
Description: In a hypothetical class, students take two midterms and an optional final. If a student takes the final and gets in it a better score than the lowest of the two midterm scores, then the lowest midterm score would be replaced by the comprehensive final score. The overall score will then be calculated by averaging the three test scores. If the student does not take the optional final, the overall score is calculated using only the two midterm scores. Students’ exam scores are included in the “Question1” tab in the attached worksheet. Empty data entries for the optional comprehensive final means that the student did not take the optional final. Tasks: Task 1: In Question1_Module, code a function that requires midterm1 score, midterm2 score, and comprehensive final as inputs and calculate the overall score per the description above. Task 2: In Question1_Module, code a Sub that uses the function coded in task 1 to fill column ‘I’ of the worksheet and link this…
WRITE PLEASEJAVA write grading program for a class with the following grading policies. thers a total of 2 quizzes, each graded on the basis of 10 points. theeres  is 1 midterm exam and one final exam, each graded on the basis of 100 points. final exam counts for 50% of the grade, the midterm counts for 25%, and the 2 quizzes together count for a total of 25%. (Do not forget to normalize the quiz scores.) letter grade will be given based on the following criterion: 90 – 100  A 80 – 89    B 70 – 79    C 60 – 69    D 0 – 59      E             program will read student’s scores from a txf file, save them in an arrayor arrays), process the arrays),  print the student’s record, which consists of the name, 2 quiz and 2 exam scores as well along with students avg numscore for the course and final letter rade.         please noteAll the scores are integers and a student name consists of no more than 10 characters. justify output file
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
6 Stages of UI Design; Author: DesignerUp;https://www.youtube.com/watch?v=_6Tl2_eM0DE;License: Standard Youtube License