This is my code....
Now, I need to write some code to do some error checking of the data. That is, if the grade point average is not between 0.0 and 4.0 or if the entrance score is not between 0 and 100, then I need an appropriate error message to the screen telling the user that they entered invalid data. How would I go about this and where would I place the code, this is driving me nuts. I already have a JOptionPane.sho w.Message Dialog (null, Invalid entry); but nothing else.
Thank you
Code:
import javax.swing.JOptionPane;
public class AdmissionsSpence
{
public static void main(String[] args)
{
String entranceScore, gradePointAverage;
gradePointAverage = JOptionPane.showInputDialog(null, "Enter your G.P.A.");
entranceScore = JOptionPane.showInputDialog(null, "Enter your Entrance score");
FinalResults(entranceScore, gradePointAverage);
}
public static void FinalResults(String entranceScore,String gradePointAverage)
{
double gPaverage;
int entScore;
gPaverage = Double.parseDouble(gradePointAverage);
entScore = Integer.parseInt(entranceScore);
if (gPaverage >= 3.0 && entScore > 60)
JOptionPane.showMessageDialog(null, "Congradulations!");
else if (entScore >= 85)
JOptionPane.showMessageDialog(null, "Congradulations!");
else
JOptionPane.showMessageDialog(null, "Try again next year!");
JOptionPane.showMessageDialog(null, "Invalid entry");
System.exit(0);
}
}
Thank you
Comment