Advertisement
Blonk

Untitled

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