PDA

View Full Version : anither tough one


Uber Fr0g
03-01-2006, 05:47 AM
I have progressed pretty far in my deitel book, but once again i hava managed to stumble upon something i have no idea how to do. This is what it says:


Write and application that displays the following patterns, but create each one in a seperate .java file. Use for loops to generate the patterns. All asteriks (*) should be printed by a single statement of the form System.out.print( '*' ); wich causes the asteriks to print side by side. A statement of the form System.out.println(); can be used to move to the next line. A statement of the form System.out.print( ' ' ); can be used to display a space for the last two patterns. There should be no other output statements in the program.


heres the patterns it wants me to print out.
(a)

*
**
***
****
*****
******
*******
********
*********
**********
(b)

**********
*********
********
*******
******
*****
****
***
**
*
(c)

**********
*********
******** I cant get this one to show up right, but the right side
******* should bestraight
******
*****
****
***
**
*
(d)


*
**
***
**** This one wont show right either, the right side should be straight.
*****
******
*******
********
*********
**********

_Aerospace_Eng_
03-01-2006, 06:09 AM
And what do you want us to do? We don't "do" homework. What have you tried?

Uber Fr0g
03-01-2006, 06:33 AM
well i have the first one, but i cant get the others


public class testFor8{
private static int maxrows = 10;
private static int row;
private static int col;


public static void main(String args[]){
for( row=1; row<=maxrows; row++ ) {
for( col = 1; col<=row;col++)
System.out.print('*');
System.out.println();
}
}
}


But i cant get the others