Computer Science Homework Solutions
Problem
#130279

GUI Components - Java - Guess the Number

Write an application that plays "guess the number" as follows: Your application chooses the number to be guessed by selecting an integer at random in the range 1-1000. The application then displays the following in a label:

I have a number between 1 and 1000. Can you guess my number?
Please enter your first guess.

A JTextField should be used to input the guess. As each guess is input, the background color should change to either red or blue. Red indicates that the user is getting "warmer," and blue indicates that the user is getting "colder." A JLabel should display either " Too High" or "Too Low" to help the user zero in on the correct answer. When the user gets the correct answer, "Correct!" should be displayed, and the JTextField used for input should be changed to be uneditable. A JButton should be provided to allow the user to play the game again. When the JButton is clicked, a new random number should be generated and the input JTextField changed to be editable.

Solution
What is this?
By OTA - Overall OTA Rating
Yupei Xiong, PhD - 4.8/5
Purchase Cost Now
$2.19 CAD (was ~$19.95)
Included in Download
  • Plain text response
  • Attached file(s):
    • GuessNumber.java
$2.19 Instant Download
Add to Cart
Why you can trust BrainMass.com
  • Your Information is Secure
  • Best Online Academic Help Service
  • Students find real academic Success
Related Solutions
  • GUI Components - Java - JPanel - Declare a subclass of JPanel called MyColorChooser that provides three JSlider objects and three JTextField objects. Each JSlider represents the values from 0 to 255 for the red, green and blue parts ...
  • Java GUI Application - I need some help with the following question: Design a drawing application (have a look at Microsoft Paint application on your Windows system). The application must have menus, and must be able to dra ...
  • Java Programming/Mortgage - Please help me create a GUI with 3 JTextField (one for loan amount, one for term, and one for interest rate), one JTextArea (where the monthly payment schedule will be displayed; appended for each mon ...
  • True or False - Determine whether each statement is true or false. If false, explain why. a) A JPanel is a JComponent b) A JPanel is a Component c) A JLabel is a Container d) A JList is a JPanel e) An Abstract ...
  • How do I begin to break down a programming idea into modules? - My task is to think of a software application that I may be asked to develope, for example, a maintenance tracking application for an apartment complex, a video store application, a gym membership and ...
Browse