Professional Documents
Culture Documents
import java.util.*;
public class GuessingGame {
if( guess<1) {
System.out.println("Lesser than the range");
counter--;
}
else if( guess<1) {
System.out.println("Over the range");
counter--;
}
else if(guess<x) {
System.out.println("Too low");
}
else if(guess<x) {
System.out.println("Too high");
}
else if(guess==x) {
System.out.println("You have guessed the right number
"+"("+counter+") "+"attempts");
break;
}
}
}
catch(Exception e) {
System.out.println("Numbers only");
System.out.println("You have guessed the right number "+"("+counter+")
"+"attempts");
counter--;
}
}
}