Your mission should you choose to accept it.
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]
Then ask the user if they would like to enter another student or quit. Continue the process until the user chooses to
quit.
This is what I have so far
import java.util.*;
public class StudentGrades {
public static void main (String[] args) {
Scanner console = new Scanner (System.in);
String sSID = "";
String sInputF = "";
String sInputL = "";
String sGrade = "";
double dWeightAssign = 50;
double dWeightQuiz = 20;
double dWeightMidE = 10;
double dWeightFinalE = 20;
double dStudentAssign = 0;
double dStudentQuiz = 0;
double dStudentMidE = 0;
double dStudentFinalE = 0;
double dTotalAssign = 0;
double dTotalQuiz = 0;
double dTotalMidE = 0;
double dTotalFinalE = 0;
double dTotalScore = 0;
//Preform calculation
dTotalAssign = dWeightAssign * dStudentAssign;
dTotalQuiz = dWeightQuiz * dStudentQuiz;
dTotalMidE = dWeightMidE * dStudentMidE;
dTotalFinalE = dWeightFinalE * dStudentFinalE;
dTotalScore = (dWeightAssign * dStudentAssign) + (dWeightQuiz * dStudentQuiz) +
(dWeightMidE * dStudentMidE) + (dWeightFinalE * dStudentFinalE);
//Get user input
System.out.println("Please enter student's ID Number.");
sSID = console.nextLine();
System.out.println("Please enter student's First Name.");
sInputF = console.nextLine();
System.out.println("Please enter student's Last Name.");
sInputL = console.nextLine();
System.out.println("Please enter student's score for Assignments");
dStudentAssign = console.nextDouble ();
System.out.println("Please enter student's score for Quizes");
dStudentQuiz = console.nextDouble ();
System.out.println("Please enter student's score for Midterm Exam");
dStudentMidE = console.nextDouble ();
System.out.println("Please enter student's score for Final Exam");
dStudentFinalE = console.nextDouble ();
if (dTotalScore >= 90) {
sGrade = "A";
}
else if (dTotalScore >= 80) {
sGrade = "B";
}
else if (dTotalScore >= 70) {
sGrade = "C";
}
else if (dTotalScore >= 60) {
sGrade = "D";
}
else {
sGrade = "F";
}
System.out.println(sGrade);
I have also tried the following for the letter grade
if (dTotalScore >= 90) {
System.out.println("A");
}
else if (dTotalScore >= 80)
{
System.out.println("B");
}
else if (dTotalScore >= 70)
{
System.out.println("C");
}
else if (dTotalScore >= 60)
{
System.out.println("D");
}
else
{
System.out.println("F");
}
Neither way has worked
}
}
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]
Then ask the user if they would like to enter another student or quit. Continue the process until the user chooses to
quit.
This is what I have so far
import java.util.*;
public class StudentGrades {
public static void main (String[] args) {
Scanner console = new Scanner (System.in);
String sSID = "";
String sInputF = "";
String sInputL = "";
String sGrade = "";
double dWeightAssign = 50;
double dWeightQuiz = 20;
double dWeightMidE = 10;
double dWeightFinalE = 20;
double dStudentAssign = 0;
double dStudentQuiz = 0;
double dStudentMidE = 0;
double dStudentFinalE = 0;
double dTotalAssign = 0;
double dTotalQuiz = 0;
double dTotalMidE = 0;
double dTotalFinalE = 0;
double dTotalScore = 0;
//Preform calculation
dTotalAssign = dWeightAssign * dStudentAssign;
dTotalQuiz = dWeightQuiz * dStudentQuiz;
dTotalMidE = dWeightMidE * dStudentMidE;
dTotalFinalE = dWeightFinalE * dStudentFinalE;
dTotalScore = (dWeightAssign * dStudentAssign) + (dWeightQuiz * dStudentQuiz) +
(dWeightMidE * dStudentMidE) + (dWeightFinalE * dStudentFinalE);
//Get user input
System.out.println("Please enter student's ID Number.");
sSID = console.nextLine();
System.out.println("Please enter student's First Name.");
sInputF = console.nextLine();
System.out.println("Please enter student's Last Name.");
sInputL = console.nextLine();
System.out.println("Please enter student's score for Assignments");
dStudentAssign = console.nextDouble ();
System.out.println("Please enter student's score for Quizes");
dStudentQuiz = console.nextDouble ();
System.out.println("Please enter student's score for Midterm Exam");
dStudentMidE = console.nextDouble ();
System.out.println("Please enter student's score for Final Exam");
dStudentFinalE = console.nextDouble ();
if (dTotalScore >= 90) {
sGrade = "A";
}
else if (dTotalScore >= 80) {
sGrade = "B";
}
else if (dTotalScore >= 70) {
sGrade = "C";
}
else if (dTotalScore >= 60) {
sGrade = "D";
}
else {
sGrade = "F";
}
System.out.println(sGrade);
I have also tried the following for the letter grade
if (dTotalScore >= 90) {
System.out.println("A");
}
else if (dTotalScore >= 80)
{
System.out.println("B");
}
else if (dTotalScore >= 70)
{
System.out.println("C");
}
else if (dTotalScore >= 60)
{
System.out.println("D");
}
else
{
System.out.println("F");
}
Neither way has worked
}
}