Question

Write a method using for loops to produce the following output for a given value of...

Write a method using for loops to produce the following output
for a given value of a parameter. (parm = 5 is shown):

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

please help me

This java program im sorry
0 0
Add a comment Improve this question Transcribed image text
Answer #1

public class Main
{
   public static void main(String[] args) {
       int n = 5;
printStars(n);
   }
   public static void printStars(int n)
{
int i, j;
// outer loop to handle number of rows
// n in this case
for(i=0; i<n; i++)
{
// inner loop to handle number of columns
// values changing acc. to outer loop   
for(j=0; j<=i; j++)
{
// printing stars
System.out.print("* ");
}
// ending line after each row
System.out.println();
}
}
}

Add a comment
Know the answer?
Add Answer to:
Write a method using for loops to produce the following output for a given value of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT