This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes how to print a christmas tree? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "how to print a christmas tree?" Watch "how to print a christmas tree?" New topic
Author

how to print a christmas tree?

Lim Youjie
Greenhorn

Joined: Dec 27, 2004
Posts: 22
hi, im a newbie to java.

this program allows the user to input the height of the christmas tree.
but i m not sure of the codings for the loop.
e.g the height indicate by user is 4

*
***
*****
*******

e.g the height indicate by user is 3

*
***
*****
Martyn Clark
Ranch Hand

Joined: Apr 16, 2005
Posts: 108
Hi Lim i don't quite understand what you are trying to do with the loop and user input can you explain a little better or post some code.


Martyn...<br /> <br />SCJP 1.4 SCWCD 1.4
Lim Youjie
Greenhorn

Joined: Dec 27, 2004
Posts: 22
Seb Mathe
Ranch Hand

Joined: Sep 28, 2005
Posts: 225
using char ast = '*';

you can do :

char[] line = new char[2*i-1];
java.util.Arrays.fill(line, c);
System.out.println(line);
[ October 11, 2005: Message edited by: Seb Mathe ]

Regards,<br />Seb<br /> <br />SCJP 1.4
Lim Youjie
Greenhorn

Joined: Dec 27, 2004
Posts: 22
may i know wats c?
thanks
Lim Youjie
Greenhorn

Joined: Dec 27, 2004
Posts: 22
thanks think i understand Martyn Clark and Seb Mathe.
you guys are great.
Seb Mathe
Ranch Hand

Joined: Sep 28, 2005
Posts: 225
oops, "c" is "ast"

char c = '*';
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to print a christmas tree?
 
Similar Threads
The Beauty of Mathematics
WA #1.....word association
WA #2 ..... word association
PA #1.....picture association
How dumb are you?