Problem

Create an applet or GUI application that plays a simple guessing game. Give it two buttons...

Create an applet or GUI application that plays a simple guessing game. Give it two buttons labeled Odd and Even. The user must guess whether a secret number is odd or even by clicking one of these buttons. After a guess is made, the applet should display either Congratulations, you are correct! or Sorry, you are wrong. In either case, also display The secret number was: followed by the secret number. Use labels for these three messages.

The program will have a private instance variable secretNumber of type long that holds the secret number. You will need to set it in the init method using the following line of code:

secretNumber =	java.util.Calendar.getInstance().getTimeInMillis() % 100;

In the actionPerformed method, check which button was pressed and make the appropriate response label visible. After that, make the two buttons invisible (only one guess is allowed) and the label containing the secret number visible.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 6
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT