Question: Java problem /** * Prints a pattern of 2n rows containing dashes and stars, * as illustrated below for n = 5. Note that the

Java problem

/** * Prints a pattern of 2n rows containing dashes and stars, * as illustrated below for n = 5. Note that the first row * starts with exactly n - 1 spaces and the middle rows have * no spaces. * *

 * *----**---- *---* *--- *--* *-- *-* *- ** * ** * *-* *- *--* *-- *---* *--- *----**---- * 

* * @param n * one-half the number of rows in the output */

a.write a helper method that, given a number d,constructs andreturnsa String ofd dashes?

b.write a helper method that, given number d and a number n > d, returns a String of the correct formfor one line of the output? (For example, given n = 5 and d= 3, return the 10-character string"---**---")

c.write an algorithm to just print out the number of dashes that should appear at the beginning of each line? (For example, if n = 5, you'd print 4, 3, 2, 1, 0, 0, 1, 2, 3, 4)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!