I am trying to create a program that prompts the user to enter in the weight of the package and display the cost. I am new to the switch statement, which is why I feel it may have something to do with those statements. However, I return the error "cannot convert from boolean to int". I have looked at other situations where this comes up, but have not found a solution. Using == did not change it.
import java.util.Scanner;
public class Exercise03_18 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter the weight of the package: ");
int weight = input.nextInt();
switch (weight) {
case weight <= 1:
System.out.println("The cost is 3.5");
break;
case weight <= 3:
System.out.println("The cost is 5.5");
break;
case weight <= 10:
System.out.println("The cost is 8.5");
break;
case weight <= 20:
System.out.println("The cost is 10.5");
default: System.out.println("The package cannot be shipped");
}
}
}