Skip to content

Instantly share code, notes, and snippets.

@isauravmanitripathi
Created April 10, 2019 21:26
Show Gist options
  • Select an option

  • Save isauravmanitripathi/551114b0b585f242b792b46c10040779 to your computer and use it in GitHub Desktop.

Select an option

Save isauravmanitripathi/551114b0b585f242b792b46c10040779 to your computer and use it in GitHub Desktop.
class Guess {
public static void main (String [] args)
throws java.io.IOException {
char ch, answer = 'K';
System.out.println("I'm thinking of a letter between A and Z");
System.out.println("Can you guess it: ");
ch = (char) System.in.read(); // read a char from the keyboard
if (ch == answer) {
System.out.println("**Winner**");
}
else {
System.out.println("**Loser**");
//nested if starts here
if (ch < answer) System.out.println("naah too low try again");
else System.out.println("come down too high g");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment