Hey. This is my first post on this forum, and I'm just coming for a little help. I just started to teach myself Java yesterday, and i am having trouble writing a switch statement.
The error:
When I attempt to compile my program, I am told:
test.java:12 ';' expected
Switch(x)
test.java:14: orphaned case
case x>70
Regarding the first error, everything that I've read states that a ";" is not needed after a switch declaration. I'm not sure why the compiler would be calling for this.
I really have no idea what's up the the orphaned case error. Other threads and websites and suggested faulty bracket placement, but I have already checked and re-written every bracket. Any ideas.
Thank you.
[code]
public class test
{
public static void main(String args[])
{
System.out.println("\n Enter an integer");
Scanner s = new Scanner(System.in);
int x = s.nextInt();
Switch(x)
{
case x>70:
System.out.println("Exceeding speed limit");
break;
case 65<x<=70:
System.out.println("Getting close");
break;
case x==65:
System.out.println("Cruising");
break;
case x<65:
System.out.println("Slow");
}
}
}
[/CODE}