In: Computer Science
Need someone to rewrite this code to work in the same way:
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 score of "+testScore+" is an F.");
else if (testScore < 70)
JOptionPane.showMessageDialog(null, "Your score of "+testScore+" is a D.");
else if (testScore < 80)
JOptionPane.showMessageDialog(null, "Your score of "+testScore+" is a C.");
else if (testScore < 90)
JOptionPane.showMessageDialog(null, "Your score of "+testScore+"e is a B.");
else
JOptionPane.showMessageDialog(null, "Your score of "+testScore+" is an A.");
}
}
Need ans asap......
public class PrintGrade {
public static void main(String[] args) {
int testScore; // variable to score
int score
String message="";
// reading user input and
converting the integer to string
testScore = Integer
.parseInt(JOptionPane.showInputDialog("Enter
your numeric test score and I will tell you the grade: "));
// Display the grade.
if (testScore >= 90)
message="Your
score of " + testScore + " is an A.";
else if (testScore >= 80)
message="Your
score of " + testScore + "e is a B.";
else if (testScore >= 70)
message="Your
score of " + testScore + " is a C.";
else if (testScore >= 60)
message="Your
score of " + testScore + " is a D.";
else
message="Your
score of " + testScore + " is an F.";
JOptionPane.showMessageDialog(null,
message);
}
}
Note : If you like my answer please rate and help me it is very Imp for me