Results 1 to 2 of 2
  1. #1
    helostcontrol is offline Member
    Join Date
    Dec 2011
    Rep Power

    Default Star triangle with boolean array

    Hey guys.
    My task is to print out a equal-sided triangle, like this:

    (__ are empty spaces)

    I have to use a boolean[][] array. Everytime when a star has to be drawn, true should be returned. If a space character, false should be returned.
    Heres my code.
    Java Code:
    public class Application { 
      public static void main(String[] args) { 
    	  int eingabe = 3;
    	  int anzahl = eingabe;
    	  boolean[][] matrix = new boolean[eingabe][];
    	  for ( int j = 0; j<matrix.length ; j++ ){
    		for(int i=0; i<anzahl; i++)
    		matrix[ j ]= new boolean[ j + eingabe];
    	  for ( int i = 0 ; i < matrix.length ; i++ )
    	  { for ( int j = 0 ; j < matrix[i].length ; j++ )
    	  System.out.print( matrix[i][j] + " " );
    I hope someone can help me. Thanks!!

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power

    Default Re: Star triangle with boolean array

    Do you have a question?
    Does you code compile and execute? What happens?
    Copy and post here the output from your code if you are asking for help with your program.

    What is the logic for your code? What does it do for each row?
    How many spaces and how many *s does it output for each row?
    What is the relationship between the row number and the number of spaces and the number of *s

    One thing I don't see is the '*' character that is to be printed out.

Similar Threads

  1. Star triangle with boolean array
    By helostcontrol in forum New To Java
    Replies: 1
    Last Post: 01-05-2012, 01:15 AM
  2. Replies: 3
    Last Post: 09-13-2011, 12:01 AM
  3. Boolean array Question
    By elm101 in forum New To Java
    Replies: 10
    Last Post: 06-01-2011, 07:02 AM
  4. Star triangle pattern
    By crazy4fun in forum New To Java
    Replies: 7
    Last Post: 03-06-2011, 01:03 PM
  5. star array
    By nanna in forum New To Java
    Replies: 4
    Last Post: 11-23-2008, 07:58 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts