Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is the Java code I have so far for a grading program. The directions are be

ID: 3745271 • Letter: T

Question

This is the Java code I have so far for a grading program. The directions are below the code. For some reason my program outputs the wrong grade. If someone could fix this error that would be great. I have the Grading class and the Main seperated.

Grading.Java

Write a grading program for a class with the following grading policies: a. There are three quizzes, each graded on the basis of 10 point:s b. There is one midterm exam, graded on the basis of 100 points. c. 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. (Do not forget to convert the quiz scores to percentages before they are averaged 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 should read in the student's scores and output the student's record, which consists of three quiz scores and two exam scores, as well as the student's overall numeric score for the entire course and final letter grade. Define and use a class for the student record. The class should have instance variables for the quizzes, midterm, final, overall numeric score for the course, and final letter grade. The overall numeric score is a number in the range 0 to 100, which represents the weighted average of the student's work. The class should have methods to compute the overall numeric grade and the final letter grade. These last methods should be void methods that set the appropriate instance variables. Your class should have a reasonable set of accessor and mutator methods. You may add other methods if you wish.

Explanation / Answer

Grading.java

import java.text.DecimalFormat;

public class Grading {

//variables

private double quiz1;
private double quiz2;
private double quiz3;
private double midTerm;
private double finalExam;
private char grade;
private double overAllScore;
//constructor

Grading() {
quiz1 = 0;
quiz2 = 0;
quiz3 = 0;
midTerm = 0;
finalExam = 0;
grade = 'F';
overAllScore = 0;
}
//setters and getters for all variables
public void setQ1(double quiz1) {
this.quiz1 = quiz1;
}
public double getQ1() {

return quiz1;
}
public void setQ2(double quiz2) {

this.quiz2 = quiz2;
}
public double getQ2() {
return quiz2;
}
public void setQ3(double quiz3) {
this.quiz3 = quiz3;
}
public double getQ3() {
return quiz3;
}

public void setMidTerm(double midTerm) {
this.midTerm = midTerm;
}
public double getMidTerm() {
return midTerm;
}
public void setFinalExam(double finalExam) {
this.finalExam = finalExam;
}
public double getFinalExam() {
return finalExam;
}
public void setGrade(char grade) {
this.grade = grade;
}

//method to calculate grade

public void CalculateGrade() {
overAllScore = overAllScore + ((double)(getQ1() + getQ2() + getQ3()) / 30) * 25;
overAllScore = overAllScore + ((double)(getMidTerm()) / 100) * 35;
overAllScore = overAllScore + ((double)(getFinalExam()) / 100) * 40;
if (overAllScore >= 90)
setGrade('A');
else if (overAllScore >= 80)
setGrade('B');
else if (overAllScore >= 70)
setGrade('C');
else if (overAllScore >= 60)
setGrade('D');
else
setGrade('F');
}
public String toString() {
//DecimalFormat class is used to format the output
DecimalFormat df = new DecimalFormat("#.##");
return "Final Grade : " + grade + " (" + df.format(overAllScore) + "%)";
}

//create string for grade


}

___________________

Main.java

import java.util.Scanner;
public class Main {
public static void main(String[] args) {

Grading g = new Grading();
Scanner sc = new Scanner(System.in); //scanner object
double x;

System.out.print("Enter quiz 1 score: ");
x = sc.nextDouble();
g.setQ1(x);
System.out.print("Enter quiz 2 score: ");

x = sc.nextDouble();
g.setQ2(x);
System.out.print("Enter quiz 3 score: ");

x = sc.nextDouble();
g.setQ3(x);
System.out.print("Enter mid-term score: ");

x = sc.nextDouble();
g.setMidTerm(x);
System.out.print("Enter final exam score: ");

x = sc.nextDouble();
g.setFinalExam(x);
g.CalculateGrade();
System.out.println(g);
sc.close();
}
}

_________________

Output;

Enter quiz 1 score: 9
Enter quiz 2 score: 8
Enter quiz 3 score: 7
Enter mid-term score: 70
Enter final exam score: 70
Final Grade : C (72.5%)

_______________Could you plz rate me well.Thank You

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote