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 record. Note: input/output should be done with files. The organization for the input file is as follows: The number at the top represents the number of students in a class. Following are students’ records, which consist of 6 items:  student ID  name  quiz 1  quiz 2  midterm exam  final exam public class Student{ private String studentID; private String name; private int quiz1; private int quiz2; private int midterm; private int finalexam; private double avg; private String grade; public Student () { // TODO initialize all the private data members (id="na", n="na", quiz1=0, quiz2=0, // midterm=0, finalexam=0, avg=0.0, grade="na") // Here is an example this("na","na", 0, 0, 0, 0, 0.0, "na"); } public Student (String id, String n, int q1, int q2, int m, int f) { // TODO initialize all the private data members with the given arguments, while the grade is "na" // Here is an example this(id, n, q1, q2, m, f, 0.0, "na"); } public Student (String id, String n, int q1, int q2, int m, int f, double a, String letterGrade) { // TODO initialize all the private data members with the given arguments // Here is an example studentID=id; name=n; quiz1=q1; quiz2=q2; midterm=m; finalexam=f; avg=a; grade=letterGrade; } public void set(String id, String n, int q1, int q2, int m, int f, double a, String g) { // TODO set all the private data members with the given arguments } public void calcAvg() { // TODO Calculate the average grade (avg) based on the student's scores (quiz1, quiz2, midterm and finalexam) } public void calcGrade() { // TODO Calculate the letter grade (A, B, C, D and F) based on the student's average grade (avg) } public String getID() { // TODO return studentID // Here is an example return studentID; } public String getName() { // TODO return name return "na"; } public int getQuiz1() { // TODO return quiz1 return 0; } public int getQuiz2() { // TODO return quiz2 return 0; } public int getMidterm() { // TODO return midterm return 0; } public int getFinalexam() { // TODO return finalexam return 0; } public double getAvg() { // TODO calculate the average grade and return the calculated value (avg) return 0.0; } public String getGrade() { // TODO calculate the letter grade and return the calculated value (grade) return "na"; } }  Please answer using Java

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 20PE: When you borrow money to buy a house, a car, or for some other purpose, you repay the loan by making...
icon
Related questions
Question

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 record. Note: input/output should be done with files.
The organization for the input file is as follows: The number at the top represents the number of students in a class. Following are students’ records, which consist of 6 items:
 student ID
 name
 quiz 1
 quiz 2
 midterm exam
 final exam

public class Student{

private String studentID;

private String name;

private int quiz1;

private int quiz2;

private int midterm;

private int finalexam; private double avg;

private String grade;

public Student () {

// TODO initialize all the private data members (id="na", n="na", quiz1=0, quiz2=0,

// midterm=0, finalexam=0, avg=0.0, grade="na")

// Here is an example this("na","na", 0, 0, 0, 0, 0.0, "na");

}

public Student (String id, String n, int q1, int q2, int m, int f)

{

// TODO initialize all the private data members with the given arguments, while the grade is "na"

// Here is an example this(id, n, q1, q2, m, f, 0.0, "na");

}

public Student (String id, String n, int q1, int q2, int m, int f, double a, String letterGrade)

{

// TODO initialize all the private data members with the given arguments

// Here is an example studentID=id; name=n; quiz1=q1; quiz2=q2; midterm=m; finalexam=f; avg=a; grade=letterGrade;

}

public void set(String id, String n, int q1, int q2, int m, int f, double a, String g)

{

// TODO set all the private data members with the given arguments

}

public void calcAvg()

{

// TODO Calculate the average grade (avg) based on the student's scores (quiz1, quiz2, midterm and finalexam)

}

public void calcGrade()

{

// TODO Calculate the letter grade (A, B, C, D and F) based on the student's average grade (avg)

}

public String getID()

{

// TODO return studentID

// Here is an example return studentID;

}

public String getName()

{

// TODO return name return "na";

}

public int getQuiz1()

{

// TODO return quiz1 return 0;

}

public int getQuiz2()

{

// TODO return quiz2 return 0;

}

public int getMidterm()

{

// TODO return midterm return 0;

}

public int getFinalexam()

{

// TODO return finalexam return 0;

}

public double getAvg()

{

// TODO calculate the average grade and return the calculated value (avg) return 0.0;

}

public String getGrade()

{

// TODO calculate the letter grade and return the calculated value (grade) return "na";

}

Please answer using Java

Expert Solution
Step 1

Coded in c++

Programming comments are written.

Logic:

Average is calculated after giving weightage to each marks.

Function grading with attribute average is created which returns grade by if else statements.  Firstly marks are compared if they are equal or more than 90 if it is grade 'A' is returned, now if it is false we move to next else if and compare if marks are greater than or equal to 80,then 'B' is returned. This way we do it for all grades.

#include<iostream>
using namespace std;
char grading(double average)
{
    if(average>=90)
    {
        return 'A';
    }
   else if(average>=80)
    {
        return 'B';
        }       
        else if(average>=70)
        {
        return 'C';
        }
        else if(average>=60)
        {
        return 'D';
        }
        else
        {
        return 'F';
    }
}
int main()
{       
        double quiz1,quiz2,midexam,finalexam;//all variable are defined
        cout<<"Enter marks in quiz1: ";
        cin>>quiz1;//user have to enter the marks
        cout<<"Enter marks in quiz2: ";
        cin>>quiz2;//user have to enter the marks
        cout<<"Enter marks in midsem: ";
        cin>>midexam;//user have to enter the marks
        cout<<"Enter marks in finalexam: ";
        cin>>finalexam;//user have to enter the marks
        cout<<endl;
        
        //0.1225 is multiplied with quizzes as there both together weightage is 25% and single weightage should be 12.25%
        //quizzes are also multiplied by 10 as there marks in 10 and we want result out of 100
        //final and mid sem weightage is 50% so multiplied by 0.5
        double average=0.1225*quiz1*10+0.1225*quiz2*10+0.5*finalexam+0.25*midexam;
        
        //function call is done and average is sent as parameter
        char grade=grading(average);
        
        //Outputs will be printed by below statements
        cout<<"Marks in quiz 1= "<<quiz1<<endl;
        cout<<"Marks in quiz 2= "<<quiz2<<endl;
        cout<<"Marks in midsem= "<<midexam<<endl;
        cout<<"Marks in final = "<<finalexam<<endl;
        cout<<"Average numeric score= "<<average<<endl;
        cout<<"Grade of student= "<<grade;
}

Output:

C:\Users\DELL\Desktop\sorted.exe Enter marks in quiz1: 7 Enter marks in quiz2: 9 Enter marks in midsem: 89 Enter marks in fin

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
ADT and Class
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
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning