Guest User

Untitled

a guest
Sep 22nd, 2018
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. Write a program that guesses the user's first name one letter at a time:
  2. 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()
  3. 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.
  4. You can cast from an integer to the corresponding Unicode character this way: char myChar = (char) x;
  5. The opposite cast looks like this: int x = (int) myChar;
  6. You may use all caps to make things easier
  7. 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.
  8. 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