Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Write a program that guesses the user's first name one letter at a time:
- Your name-guessing program should have an outer loop that continues until the user indicates that all letters of his/her name have been guessed. For this step, you may want to use JOptionPane.showConfirmDialog(), and have the loop break on either "No" or "Cancel" responses. You could also use showOptionDialog()
- Use a separate method that guesses the current letter. This method should contain a loop that makes guesses until the current letter has been guessed correctly. Each time through this loop, generate a guess and ask if it is correct, earlier in alphabetical order, or later in alphabetical order than the current letter of the user's first name. Adjust subsequent guesses accordingly.
- You can cast from an integer to the corresponding Unicode character this way: char myChar = (char) x;
- The opposite cast looks like this: int x = (int) myChar;
- You may use all caps to make things easier
- It will be hard for the user to make it through this game without any input mistakes. Use your imagination to look for ways to make it easier.
- Once the name has been guessed correctly, show a thank you message that includes the entire name, eg: "Thanks for playing, JOHN!"
Add Comment
Please, Sign In to add comment