Hi there,I am stuck here.The question ask to Write an application for a university admissions office. Prompt the user for a
student’s High School Grade Point and an admission test score
(value from 0 to 100). Print the message “Accept” if the student has any of the
following:
A grade point of 3.0 or above and an admission test score of at least 60.
A grade point below 3.0 and an admission test score of at least 80.
If student does not meet either of the qualification criteria, print “Reject”.
I manage to do that below are the codes.
import javax.swing.*;
class apple{
public static void main(String[] args){
double gp = 4.0;
int ts = 100;
gp = doubleValue(
JOptionPane.showInputDialog(
null, "Enter Grade point: "));
ts = Integer.parseInt(
JOptionPane.showInputDialog(
null, "Enter Test score: "));
if (gp >= 3.0 && ts >= 60){
JOptionPane.showMessageDialog(null, "Accept");
} else if (gp <= 3.0 && ts >= 80){
JOptionPane.showMessageDialog(null, "Accept");
}else {
JOptionPane.showMessageDialog(null, "Reject");
}
}
private static double doubleValue(String showInputDialog) {
return 0;
}
}
But when to Modified it , So that if a user enters a grade point under 0 or over 4.0, or a test score under 0 or over 100, an error message appears instead of the“Accept” or “Reject” message.
So far what I try the below code but Fail. Am i missing something?
import javax.swing.*;
public class apples {
public static void main(String[] args){
double gp = 4.0;
int ts = 100;
gp = doubleValue(
JOptionPane.showInputDialog(
null, "Enter Grade point: "));
ts = Integer.parseInt(
JOptionPane.showInputDialog(
null, "Enter Test score: "));
if (gp >= 3.0 && ts >= 60){
JOptionPane.showMessageDialog(null, "Accept");
} else if (gp <= 3.0 && ts >= 80){
JOptionPane.showMessageDialog(null, "Accept");
} else if (gp <= 0.0 && ts <= 0){
JOptionPane.showMessageDialog(null, "Invalid Result");
} else if (gp > 4.0 && ts > 100){
JOptionPane.showMessageDialog(null, "Invalid Result");
}else {
JOptionPane.showMessageDialog(null, "Reject");
}
}
private static double doubleValue(String showInputDialog) {
return 0;
}
}
Can you please advise me how to modified it, I did try google and daniweb,but notting much . Thanks in advance