Question: IfElseChain, I need this ifelse chain redone to switch statement. import javax.swing.JOptionPane; class Main { public static void main(String[] args) { int testScore; // Numeric

IfElseChain, I need this ifelse chain redone to switch statement.

import javax.swing.JOptionPane;

class Main { public static void main(String[] args) {

int testScore; // Numeric test score

String input; // To hold the user's input // Get the numeric test score.

input = JOptionPane.showInputDialog("Enter your numeric " + "test score and I will tell you the grade: ");

testScore = Integer.parseInt(input); // Display the grade.

if (testScore < 60) JOptionPane.showMessageDialog(null, "Your grade is F.");

else if (testScore < 70) JOptionPane.showMessageDialog(null, "Your grade is D.");

else if (testScore < 80) JOptionPane.showMessageDialog(null, "Your grade is C.");

else if (testScore < 90) JOptionPane.showMessageDialog(null, "Your grade is B.");

else if (testScore <= 100) JOptionPane.showMessageDialog(null, "Your grade is A.");

else JOptionPane.showMessageDialog(null, "Invalid score.");

System.exit(0);

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!