SE1011 -- Lab 3: Loops

Overview

Write a program that asks the user to guess a number between 0 and 100. After each entry by the user, the program should indicate if the number entered was lower, higher, or exactly the number that the program was "thinking" of. If the user did not guess the number exactly, the program should prompt the user to guess again. When the user guesses the correct number, the program must display a congratulator message that includes the number of guesses that were required to guess the number correctly.

Details

  • The program must be created in a class named Lab3 that is in a package named the same as your MSOE username.
  • The program must use pop-up windows to communicate with the user.
  • The program must use the Scanner class to convert the characters entered into an integer value.
  • If the user cancels the input dialog window or does not enter any characters, the program must re-prompt the user to enter a number.
  • A random integer value may be obtained using the following code:
      java.util.Random generator = new java.util.Random();
      int randomValue = generator.nextInt(99) + 1;
    
  • If the user enters a number less than one or greater than ninety-nine, the program must display a final pop-up message that states "Ugh. The universe appears to be winning." and then end without asking for any additional guesses.

Lab Deliverables (due at the end of week 4 lab)

Demonstration

Each student must demostrate running their program to their instructor.

Submission

Each student must submit their program. The program must contain comments at the beginning of the file that include: Course name, Quarter, Assignment name, Author's name, and date (see here). Student's must use the electronic submission form to submit their code.

Enter your MSOE username for the username, select "Lab 3" for the assignment, select your Lab3.java implementation for the report file name and leave the support file name blank.

Acknowledgment

This laboratory assignment was developed by Dr. Chris Taylor.

  • © 2001-2009 Dr. Christopher C. Taylor •
  • Office: L-343 •
  • Phone: 277-7339 •
  • npǝ˙ǝosɯ@ɹolʎɐʇ