Question: Written in java, please use comments to explain the code. part 1 To fully understand generating a random number you need to learn more about
Written in java, please use comments to explain the code.
part 1
To fully understand generating a random number you need to learn more about Java classes and methods. For now, you cna use the following statement to generate and use a dialog box that displays a random number between 1 and 10:
JOptionPane.showMessageDialog(null, "The number is " + (1+(int)(Math.random() * 10)));
Write a Java application that displays two dialog boxes in sequence. The first asks you to think of a number between 1 and 10. The second display a randomly generated number; the user can see whether his or her guess was accurate. We will build on this program in future chapters.
part 2
Using the random number program you created from Chapter 1 write a program that selects a random number between two named constant values of 1 and 5 and asks the user to input their guess. Display a message that displays the difference between the two numbers. Display another message that displays the random number and the Boolean true or false depending on whether the user's guess was equal to the random number. An example of using constants to create a random number is:
random = MIN + (int)(Math.random) * MAX;
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
