Advertisement
Guest User

Untitled

a guest
Oct 24th, 2014
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. import java.util.Random;
  2. public class Main {
  3. private static int r = 0;
  4.  
  5. public static void main(String[] args) {
  6. Random randomGenerator = new Random();
  7.  
  8.  
  9. while (r != 4) { // repeat experiment until r be 4
  10. if (randomGenerator.nextInt(4) == 2) {
  11. r++;
  12. System.out.println("The Count Variable has changed to:" + r);
  13.  
  14. }
  15. if (r == 4) {
  16. break;
  17. } else {
  18. System.out.println("Another unsuccessful trial has occurred, Count value is: " + r);
  19. }
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement