Currently struggling to grasp what my error messages mean. I understand that it doesn't like that I'm changing from a float to an int, but how can I get around that?
import java.util.Scanner;
public class gradeAverage {
public static void main (String [] args) {
Scanner sc = new Scanner(System.in);
System.out.println("First test score?");
float test1 = sc.nextInt();
System.out.println("Second test score?");
float test2 = sc.nextInt();
System.out.println("Third test score?");
float test3 = sc.nextInt();
float testAverage = (test1 + test2 + test3)/3;
System.out.println("Your test average is " + testAverage + ".");
switch(testAverage) {
case(97.5 <= testAverage <= 100):
System.out.println("Grade is an A+");
break;
case(93.5 <= testAverage <= 97.49):
System.out.println("Grade is an A");
break;
case(89.5 <= testAverage <= 93.49):
System.out.println("Grade is an A-");
default:
System.out.println("Grade is below an A-");
}
}
}
error
gradeAverage.java:13: error: incompatible types: possible lossy conversion from float to int
switch(testAverage) {
^
gradeAverage.java:14: error: bad operand types for binary operator '<='
case(97.5 <= testAverage <= 100):
^
first type: boolean
second type: int
2 errors