- Joined
- Feb 15, 2011
Well I am stuck on the following java code:
The main method should be calling the "accepted" method and giving it the user input for testGPA and testScore. The class compiles and will accept the input but it does not apply the "if" commands. Any pointers would be appreciated!
Code:
import javax.swing.JOptionPane;
public class College {
private static void accepted
(double testGPA, int testScore){
if (testGPA >= 0.0 && testGPA <= 4.0 && testScore >= 0 && testScore <= 100){
if(testGPA >= 3.0 && testScore >= 60 || testScore >= 85){
System.out.println("Student is ACCEPTED to university!");
System.out.println("Students GPA is a " + testGPA + " and students test score is a " + testScore + "%");
}
else {
System.out.println("Student is NOT ACCEPTED to university!");
System.out.println("Students GPA is a " + testGPA + " and students test score is a " + testScore + "%");
}
}
else{
System.out.println("Input INVALID please Check GPA and Test score input!");
System.out.println("Your inputs were:");
System.out.println(testGPA + " = GPA should be between 0.0 and 4.0.");
System.out.println(testScore + " = Test Score should be between 0 and 100");
}
}
public static void main(String[] args) {
String gpaString, testString;
gpaString = JOptionPane.showInputDialog(null,
"Please enter your GPA.", "GPA",
JOptionPane.PLAIN_MESSAGE);
testString = JOptionPane.showInputDialog(null,
"Please enter your entrance exam score.", "Test Score",
JOptionPane.PLAIN_MESSAGE);
double testGPA = Double.parseDouble(gpaString);
int testScore = Integer.parseInt(testString);
}
}
The main method should be calling the "accepted" method and giving it the user input for testGPA and testScore. The class compiles and will accept the input but it does not apply the "if" commands. Any pointers would be appreciated!