Question: Java program Write a method called printDesign that produces the following output using nested for loops to print out the structure. If I call printDesign(6);
Java program
Write a method called printDesign that produces the following output using nested for loops to print out the structure.
If I call printDesign(6); --------1-------- -------222------- ------33333------ -----4444444----- ----555555555---- ---66666666666---
Your method should look like the following.
public static void printDesign(int height){ .... } Note that in the example above height = 6 AND it prints 6 rows. If I change height to another number, it should then print a different number of rows. Your program should adjust itself based upon the value of height.
For example... if I change it so that
printDesign(3);
it should print
--------1-------- -------222------- ------33333------
But... if I change it so that
printDesign(12);
it should print
--------1-------- -------222------- ------33333------ -----4444444----- ----555555555---- ---66666666666--- --7777777777777-- -888888888888888- 99999999999999999 0000000000000000000 111111111111111111111
Notes:
There are 9 '-''s in the first row.
On line 10 it only prints the 0, not 10
On line 11 it prints 1 not 11
After line 9 it goes off the edge, this is normal.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
