in my program the user enters a number and the method below calculates the number and gives the user a message based on the number they entered, however I use an if statement to calculate what message to give on the number but when the user enters the number it displays all the messages, the numbers are in sets of 10 which means if the user entered a number from 40 to 49 then it would output the E grade message, can someone tell me how it can be made so that it only gives me the message for the specified numbers it is compared against?
public void checkInputScore() {
if (convertedInputScore == -1) {
System.exit(0);
}
if (convertedInputScore < 39) {
JOptionPane.showMessageDialog(Program1.this, "The student received a fail grade", "Student mark checker", JOptionPane.INFORMATION_MESSAGE);
}
if (convertedInputScore <= 49) {
JOptionPane.showMessageDialog(Program1.this, "The student received an E grade", "Student mark checker", JOptionPane.INFORMATION_MESSAGE);
}
if (convertedInputScore <= 59) {
JOptionPane.showMessageDialog(Program1.this, "The student received an D grade", "Student mark checker", JOptionPane.INFORMATION_MESSAGE);
}`
Use an
else ifstatement.