Reputation:
package gpatogradecalculator;
import java.util.Scanner;
public class GPAtoGradeCalculator {
public static void main(String[] args) {
// TODO code application logic here
double GPA = 0.0;
Scanner response = new Scanner(System.in);
System.out.println("Please enter your GPA: ");
GPA = response.nextDouble();
if(GPA >= 3.5); {
System.out.println("Your GPA is an A.");
} else if(3.0<=GPA && GPA<3.5); {
System.out.println("Your GPA is a B.");
} else if(2.5<=GPA && GPA <3.0); {
System.out.println("Your GPA is a C.");
}
if(GPA < 2.5); {
System.out.println("You are failing.");
}
} // end main
} // end class
Can anyone tell me why this wouldn't work? I don't even know where to begin to fix it. It says that my else lines are without an if, but the if is right above them...
Upvotes: 1
Views: 71
Reputation: 6739
get rid of all ;
after if ()
or better sense conditional statement
for example :
if(GPA < 2.5); {
System.out.println("You are failing.");
}
change to
if(GPA < 2.5) {
System.out.println("You are failing.");
}
do the same process for other if statement as well
Upvotes: 2