Advertisement
IanO-B

Untitled

Mar 5th, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. import java.util.Random;
  2. public class Main {
  3.  
  4. public static void main(String[] args) throws InterruptedException {
  5. Random rng = new Random();
  6. int r;
  7.  
  8. for (int i = 0; i < 100000; i++) {
  9. r = 1 + rng.nextInt(5);
  10.  
  11. if (r == 1) {
  12. first();
  13. }
  14. if (r == 2){
  15. second();
  16. }
  17. if (r == 3){
  18. third();
  19. }
  20. if (r == 4){
  21. fourth();
  22. }
  23. if (r == 5){
  24. fifth();
  25. }
  26.  
  27. Thread.sleep(1);
  28. }
  29. System.out.println("I pledge allegiance to the flag.");
  30. }
  31. public static void first()
  32. {
  33. System.out.print("I \r");
  34. }
  35.  
  36. public static void second()
  37. {
  38. System.out.print(" pledge \r");
  39. }
  40.  
  41. public static void third()
  42. {
  43. System.out.print(" allegiance \r");
  44. }
  45.  
  46. public static void fourth()
  47. {
  48. System.out.print(" to the \r");
  49. }
  50.  
  51. public static void fifth()
  52. {
  53. System.out.print(" flag.\r");
  54. }
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement