Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- public class Main
- {
- public static void main( String[] args )
- {
- Random rng = new Random();
- int r;
- for ( int i=0; i<100000; i++ )
- {
- r = 1 + rng.nextInt(5);
- // Write five if statements here.
- if (r == 1){
- System.out.println("First ");
- }
- if (r == 2){
- System.out.println("Second ");
- }
- if (r == 3){
- System.out.println("Third ");
- }
- if (r == 4){
- System.out.println("Fourth ");
- }
- if (r == 5){
- System.out.println("Fifth ");
- }
- // Optional: after the if statements are over, add in a slight delay.
- }
- System.out.println("I pledge allegiance to the flag.");
- }
- public static void first()
- {
- System.out.print("I \r");
- }
- public static void second()
- {
- System.out.print(" pledge \r");
- }
- public static void third()
- {
- System.out.print(" allegiance \r");
- }
- public static void fourth()
- {
- System.out.print(" to the \r");
- }
- public static void fifth()
- {
- System.out.print(" flag.\r");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement