Absolute C++
Absolute C++
6th Edition
ISBN: 9780133970784
Author: Walter Savitch, Kenrick Mock
Publisher: Addison-Wesley
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
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 two quizzes each count for 12.5%. (Do not forget to normalize the quiz scores. They should be converted to a percent before they are averaged in.)Any grades of 90 or more is an A, any grades of 80 or more (but less than 90) is a B, any grades of 70 or more (but less than 80) is a C, any grades of 60 or more (but less than 70) is a D, and any grades below 60 is an F.The program will read in students’ scores from an input file named “input.txt” and output the students’ records to a file named “output.txt”, which consist of student’s ID, name, two quizzes and two exam scores as well as the students’ average score for the course and final letter grade. Define and use a class for a student…
using Java  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 two quizzes each count for 12.5%. (Do not forget to normalize the quiz scores. They should be converted to a percent before they are averaged in.)Any grades of 90 or more is an A, any grades of 80 or more (but less than 90) is a B, any grades of 70 or more (but less than 80) is a C, any grades of 60 or more (but less than 70) is a D, and any grades below 60 is an F.The program will read in students’ scores from an input file named “input.txt” and output the students’ records to a file named “output.txt”, which consist of student’s ID, name, two quizzes and two exam scores as well as the students’ average score for the course and final letter grade. Define and use a class for a…
c++ 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 100points.c. The final exam counts for 50 percent of the grade, the midterm counts for 25percent, and the two quizzes together count for a total of 25 percent. (Do not forgetto normalize the quiz scores. They should be converted to a percent before they areaveraged in.) Any grade of 90 or more is an A, any grade of 80 or more (but lessthan 90) is a B, any grade of 70 or more (but less than 80) is a C, any grade of60 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’srecord, which consists of two quiz and two exam scores as well as thestudent’s average numeric score for the entire course and the final lettergrade. Define and use a Class for the student record.
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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
6 Stages of UI Design; Author: DesignerUp;https://www.youtube.com/watch?v=_6Tl2_eM0DE;License: Standard Youtube License