Guest User

Untitled

a guest
Dec 13th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. //Import utility
  2. import java.util.Random;
  3.  
  4. public class makeGuesses {
  5. public static void main (String [] args) {
  6. //Random rand
  7. Random rand = new Random();
  8. //Declare two integers: one for the guesses, one for the total number of guesses.
  9. int guess;
  10. int total = 0;
  11. //Produce do-while loop:
  12. do {
  13. guess = rand.nextInt(50) + 1;
  14. //Print β€œguess = β€œ + guess
  15. System.out.println("guess = " + guess);
  16. total++;
  17. }
  18. while (guess <= 47);
  19. System.out.println("total guesses = " + total);
  20. }
  21. }
Add Comment
Please, Sign In to add comment