Lesson-2.2
Lesson-2.2
import java.util.Random;
This statement goes before the program’s class definition header.
myRandom.nextInt(Limit)
This statement generates a random integer value that is greater
than or equal to 0 and less than Limit.
myRandom.nextInt(5)
myRandom.nextInt(11)
myRandom.nextInt(20)
/*
* Random Test
* Beginning Java
*/
package randomtest;
import java.util.Random;
diceNumber = myRandom.nextInt(6) + 1;
cardNumber = myRandom.nextInt(52) + 1;
yourNumber = myRandom.nextInt(101)
Project - Guess the Number Game
if (yourGuess == computerNumber)
{
System.out.println("You got it!! That's my number!");
}
2. Create a program that will add the result of three throws of die.
The user will guess the total and the result will be shown. If the
user is correct, “You Won !” will be shown, else “You Lost!” will be
displayed.