Send to a Friend

hungerforpizza's avatar

Help with a basic Java program?

Asked by hungerforpizza (247points) December 1st, 2010

I know it’s something with foreloops but I have no idea how to do this.

I use something called SavitchIn, which allows for simple user input.

1.Write a program that ask the user to enter the size of a triangle to print out
(an integer from 1 to 50) then print the triangle by printing a series of lines with
asterisks. The first line will have one asterisk, the next two, etc., each line having
one more asterisk than the previous line up to the number entered by the user; on the
next line print on less asterisk and continue by decreasing the number of asterisks by
one for each successive line until one asterisk is printed. Hint: use nested loops; the
outside loop controls the number of lines to print and the inside loop controls the
number of asterisk to print on a line. For example, if the users enters 5 output is
*
**
***
****
*****
****
***
**
*
*

Using Fluther

or

Using Email

Separate multiple emails with commas.
We’ll only use these emails for this message.