Many classes calculate a final grade by using a weighted scoring system. For exa
ID: 3622041 • Letter: M
Question
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 the grade in the other categories (Quizzes, Midterm Exam, Final Exam, etc.) and sums the grades earned in each to come up with the Final Score, and assigns a letter grade based on that score.Write a Java program that allows the teacher to calculate the grade for a student. The teacher will first enter the Student ID number, first name, and last name. This will be followed by entering in the score for each of the following categories: Assignments, Quizzes, Midterm Exam, & Final Exam
The weights for each category are as follows:
Assignments - 50%
Quizzes – 20%
Midterm – 10%
Final – 20%
Once you have the scores for each individual category, calculate a total score for the course. Then assign a letter grade to the student based on the following grade scale:
90 – 100 = A
80 – 90 = B
70 – 80 = C
60 – 70 = D
< 60 = E
Print the results in exactly the following format:
[Last Name], [First Name]
Student ID: [Student ID]
Homework: [Homework Score]
Quizzes: [Quizzes Score]
Midterm: [Midterm Score]
Final: [Final Score]
Total Score: [Total Score] Grade: [Letter Grade]
Explanation / Answer
import java.util.*; public class small { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.println("Enter Student ID"); int id = scan.nextInt(); System.out.println("Enter Student's First Name"); String first = scan.next(); System.out.println("Enter Student's Last Name"); String last = scan.next(); System.out.println("Enter " + first + "'s Assignments score"); float assign = scan.nextFloat(); System.out.println("Enter " + first + "'s quizzes score"); float quiz = scan.nextFloat(); System.out.println("Enter " + first + "'s Midterm score"); float midterm = scan.nextFloat(); System.out.println("Enter " + first + "'s Final score"); float fin = scan.nextFloat(); float a = (float)(assign * .50); float q = (float)(quiz * .20); float m = (float)(midterm * .10); float f = (float)(fin * .20); float total = a + q + m + f; String grade = ""; if(total < 60) grade = "F"; else if((total < 70) && (total > 59.5)) grade = "D"; else if((total < 80) && (total > 69.5)) grade = "C"; else if((total < 90) && (total > 79.5)) grade = "B"; else if((total 89.5)) grade = "A"; System.out.println(last + ", " + first); System.out.println("Student ID: " + id); System.out.println("Homework: " + a + " out of 50"); System.out.println("Quizzes: " + q + " out of 20"); System.out.println("Midterm: " + m + " out of 10"); System.out.println("Final: " + f + " out of 20"); System.out.println(""); System.out.println("Total Score: " + total + " Grade: " + grade); } }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.