I have been having problems in comiling a program and I was wondering how do I get rid of this error:
E:\School\CS161\Workbench\HiLow.java:37: 'else' without 'if'
else
Here is my code( it is not completely done yet...)
import cs1.Keyboard;
public class HiLow
{
//-----------------------------------------------------------------
// Plays a simple guessing game with the user.
//-----------------------------------------------------------------
public static void main (
String[] args)
{
String str, another = "y";
int GUESSNUM, MAX = 100;
float RANNUM = 0;
float TRY = 0;
System.out.print ("I'm thinking of a number between 1 and "
+ MAX + ". Guess what it is: ");
GUESSNUM = Keyboard.readInt();
while (another.equalsIgnoreCase("y")) // allows y or Y
{
if (RANNUM = 0)
RANNUM = (int) (Math.random() * MAX) + 1;
else
do
if ( GUESSNUM > RANNUM)
System.out.print ("You are guessing high, try again? (y/n)");
another = Keyboard.readString();
else
if ( GUESSNUM < RANNUM)
System.out.print ("You are guessing low, try again? (y/n)");
another = Keyboard.readString();
else
System.out.print ("Your on the Money way to go!!!");
System.out.print ("You wanna play again? (y/n)");
another = Keyboard.readString();
}
}
}
Thanks