Java Help D=

Pineapple

Just Smile.
Reaction score
576
I am having problems with this Java loop. I am using a for loop to simulate a coin flip.

The probelm is that I need it to loop 10 times. So you see 10 results. now, it only shows it once.

Code:
import java.util.Random;
public class XCoin{
public static void tenFlip( ){
    int result;
    
             for (int i = 0; i < 10; i++);
            {
                Random rand = new Random();    
                result = rand.nextInt(2)+1;
                   
                        if (result == 1){
                            System.out.println("H");
                        }
                        else {
                            System.out.println ("T");
                        }
                    }

        }
}

I don't know if this belongs here or else where, but this area seemed most appropriate.
 

Pineapple

Just Smile.
Reaction score
576
; ends statements.

attachment.php


Thanks. solved it :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top