Greetings everybody =)


My assignment: create a low resolution image of the night sky using +'s as stars and spaces as the space.
-have to use a 2 dimensional array
-can be any type of array
-choose 100 cells at random to be stars

problem: for some reason, I can't print out 100 stars but only 80 .. i've been working for a long time on this code with much frustration and with little progress..

   UW PICO(tm) 4.10                                                                      File: assignment11.java
 
// Programs purpose: prints out low resolution image of a night sky, using +'s as stars and " " as space.
// Step 1: Create a 80 x 20 2 dimensional array.
// Step 2: Choose 100 random cells to become stars.
// Step 3: Print out the night sky using " " as space and +'s as stars.
 
public class assignment11
{
 public static void main(String []args)
 {
  // List of variables
  final int scaleOne = 80; // Scale of 80
  final int scaleTwo = 20; // Scale of 20
 
  // Create an 80 x 20 2 dimensional array
  int[][] nightSky = new int[scaleOne][scaleTwo];
 
  // Randomize 100 cells for the array
  int randOne = (int)(Math.random()*scaleOne);
  int randTwo = (int)(Math.random()*scaleTwo);
 
  // Set the random 100 cells to be 0
  nightSky[randOne][randTwo] = 0;
 
  // Prints out the night sky
  for(int row = 0; row < nightSky.length; row++)
  {
   // If the random 100 cells are 0
   if(nightSky[randOne][randTwo] == 0)
   {
    // Display a star for each cell that is zero
    System.out.print("+");
   }
   for(int col = 0; col < nightSky.length; col++)
   {
    // Print out a space for the rest of the cells
    System.out.print(" ");
   }
  }
 }
}

I can't seem to find a problem in my code.. It looks like i done everything correctly.
when i try to increase the number of the math.random..., i get a arraysOutofbounds exception.. sigh