# Have a java problem 'else' without 'if' & illegal start of expression & expec



## canmike229 (Oct 14, 2010)

if you can help fix these three errors are:
'else' without 'if'
illegal start of expression
expected ';' 
and fix any other errors

import javax.swing.*;
public class highlow{
public static void main(String [] args){
int randomNumber = (int)(Math.random() *100) +1;
String myinput;
int guess=-1;
while(guess!=randomNumber){
myinput=JOptionPane.showInputDialog("enter guess");
guess=Integer.parseInt(myinput);
////////////
if(guess>randomNumber){
System.out.println("Your guess was to high");
}
else if(guess<randomNumber){
System.out.println("You are two low");

}
else {
System.out.println("You have the right number");

}
/////////////
int diff= guess- randomNumber;

else if (diff <-100) || (diff <50);
System.out.println ("Your Frizzing");
}
else if (diff <-50) || (diff < 25);
System.out.println ("Your Cold");
}
else if (diff <-25) || (diff < 15);
System.out.println("you are cool");
}
else if (diff <-15) || (diff < 10){
System.out.println("you are Warm");
}
else if (diff < -10) || (diff < 5){
System.out.println ("you are Hot");
}
else if (diff < 1) || (diff < 5);
System.out.println ("you are BOILING");
}
}
}

--------------------Configuration: <Default>--------------------
E:\highlow.java:25: 'else' without 'if'
else if (diff <-100) || (diff <50);
^
E:\highlow.java:25: illegal start of expression
else if (diff <-100) || (diff <50);
^
E:\highlow.java:28: 'else' without 'if'
else if (diff <-50) || (diff < 25);
^
E:\highlow.java:28: illegal start of expression
else if (diff <-50) || (diff < 25);
^
E:\highlow.java:31: illegal start of type
else if (diff <-25) || (diff < 15);
^
E:\highlow.java:31: ';' expected
else if (diff <-25) || (diff < 15);
^
E:\highlow.java:31: illegal start of type
else if (diff <-25) || (diff < 15);
^
E:\highlow.java:31: ';' expected
else if (diff <-25) || (diff < 15);
^
E:\highlow.java:31: <identifier> expected
else if (diff <-25) || (diff < 15);
^
E:\highlow.java:31: illegal start of type
else if (diff <-25) || (diff < 15);
^
E:\highlow.java:31: <identifier> expected
else if (diff <-25) || (diff < 15);
^
E:\highlow.java:31: '(' expected
else if (diff <-25) || (diff < 15);
^
E:\highlow.java:31: illegal start of type
else if (diff <-25) || (diff < 15);
^
E:\highlow.java:31: ';' expected
else if (diff <-25) || (diff < 15);
^
E:\highlow.java:31: <identifier> expected
else if (diff <-25) || (diff < 15);
^
E:\highlow.java:31: illegal start of type
else if (diff <-25) || (diff < 15);
^
E:\highlow.java:31: <identifier> expected
else if (diff <-25) || (diff < 15);
^
E:\highlow.java:32: '(' expected
System.out.println("you are cool");
^
E:\highlow.java:32: illegal start of type
System.out.println("you are cool");
^
E:\highlow.java:32: ';' expected
System.out.println("you are cool");
^
E:\highlow.java:32: invalid method declaration; return type required
System.out.println("you are cool");
^
E:\highlow.java:32: illegal start of type
System.out.println("you are cool");
^
E:\highlow.java:34: class, interface, or enum expected
else if (diff <-15) || (diff < 10){
^
E:\highlow.java:36: class, interface, or enum expected
}
^
E:\highlow.java:39: class, interface, or enum expected
}
^
E:\highlow.java:41: class, interface, or enum expected
System.out.println ("you are BOILING");
^
E:\highlow.java:42: class, interface, or enum expected
}
^
27 errors

Process completed.


----------



## JimmySeal (Sep 25, 2007)

The first problem is right here where the compiler says it is:

```
/////////////
int diff= guess- randomNumber;

else if (diff <-100) || (diff <50);
System.out.println ("Your Frizzing");
}
```
Also for some reason in your bunch of else if statements you're using semicolons where there should be opening braces. Also the whole condition for the if statements needs to be in its own set of parentheses:
Should be

```
else if [B]([/B](diff <-100) || (diff <50)[B]){[/B]
System.out.println ("Your Frizzing");
}
```
not


```
else if (diff <-100) || (diff <50);
System.out.println ("Your Frizzing");
}
```
You have an *else if* statement without any corresponding if statement.

You also might want to check your spelling on these:
Your guess was to high
You are two low
Your Frizzing
Your Cold​


----------

