Ok, so what I would like to do is make a picture using asterisks. The picture is supposed to be no more or less than 10 rows and in each row is supposed to be any random amount of asterisks in the range of 1-10. The only problem I'm having is that I am not getting 10 rows, instead, I am getting anywhere from 11 - 17 rows. I'm not sure what I'm missing and I appreciate any insight you can offer me. Thank you!
public class RandomPicture {
/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
// Create a Random picture using asterisks
Random rand = new Random();
for (int count = 0; count <=2; count++)
{
if (rand.nextInt(2) == 0){
System.out.println("*");
} if (rand.nextInt(2) == 0){
System.out.println("**");
} if (rand.nextInt(2) == 0){
System.out.println("***");
} if (rand.nextInt(2) == 0){
System.out.println("****");
} if (rand.nextInt(2) == 0){
System.out.println("*****");
} if (rand.nextInt(2) == 0){
System.out.println("******");
} if (rand.nextInt(2) == 0){
System.out.println("*******");
} if (rand.nextInt(2) == 0){
System.out.println("********");
} if (rand.nextInt(2) == 0){
System.out.println("*********");
} if (rand.nextInt(2) == 0){
System.out.println("**********");
}
}
}
}