Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Import utility
- import java.util.Random;
- public class makeGuesses {
- public static void main (String [] args) {
- //Random rand
- Random rand = new Random();
- //Declare two integers: one for the guesses, one for the total number of guesses.
- int guess;
- int total = 0;
- //Produce do-while loop:
- do {
- guess = rand.nextInt(50) + 1;
- //Print βguess = β + guess
- System.out.println("guess = " + guess);
- total++;
- }
- while (guess <= 47);
- System.out.println("total guesses = " + total);
- }
- }
Add Comment
Please, Sign In to add comment