Write a program to compute final grades for a course. For each student, the midt
ID: 3624598 • Letter: W
Question
Write a program to compute final grades for a course. For each student, the midterm exam score and the final exam score are known. The final grade of a student is calculated by adding the midterm score and the final exam score. For each student, the program should display the final grade of the student. To run your program, one should do the following Java Assign4 sortOption Where sortOption is a command line argument with the following meaning: no not sorted name sorted by name midterm sorted by midterm final sorted by final semester sorted by semester.Explanation / Answer
import javax.swing.JOptionPane; //Needed for JOptionPane
import java.io.*;
//Define class testScores
public class testscores
{
//Declared main function
public static void main(String[] args)
{
//Variables declartion
int midtestscore;
int finaltestscore;
double averagescore;
String input;
//Get first test score
input = JOptionPane.showInputDialog
("Enter Mid test score ");
midtestscore = Integer.parseInt(input);
//Get second test score
input = JOptionPane.showInputDialog
("Enter Final test score ");
finaltestscore= Integer.parseInt(input);
//Calculatting averagescore
averagescore = ((midtestscore + finaltestscore)/2);
//Check condition of Grade A
if (averagescore >=90 && averagescore <=100 )
JOptionPane.showMessageDialog(null , "Average of the test scores is " + averagescore + " The Grade is A");
//Check condition of Grade B
else if (averagescore >=80 && averagescore <=89 )
JOptionPane.showMessageDialog(null , "Average of the test scores is " + averagescore + " The Grade is B");
//Check condition of Grade C
else if (averagescore >=70 && averagescore <=79 )
JOptionPane.showMessageDialog(null , "Average of the test scores is " + averagescore + " The Grade is C");
//Check condition of Grade D
else if (averagescore >=60 && averagescore <=69 )
JOptionPane.showMessageDialog(null , "Average of the test scores is " + averagescore + " The Grade is D");
//Check condition of Grade F
else
JOptionPane.showMessageDialog(null , "Average of the test scores is " + averagescore + " The Grade is F");
//system pause for a while
System.exit(0);
}//End main function
}//End class testscores
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.