Created
April 10, 2019 21:26
-
-
Save isauravmanitripathi/551114b0b585f242b792b46c10040779 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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