Question: 1.1. Triangle Pattern Write a recursive method with the following specification and header: // Parameters: m - number of asterisks in the first line //

1.1. Triangle Pattern Write a recursive method with the following specification and header:

// Parameters: m - number of asterisks in the first line

// n - number of asterisks in the middle 2 lines

// Precondition: m <= n, m > 0, n > 0

// Postcondition: The method has printed a pattern of 2*(n-m+1) lines

// to the standard output. The first line contains m asterisks, the next

// line contains m+1 asterisks, and so on up to a line with n asterisks.

// Then the pattern is repeated backwards, going n back down to m.

/* Example output:

triangle(3, 5) will print this:

***

****

*****

*****

****

***

*/

public static void triangle(int m, int n)

Hint: Only one of the arguments changes in the recursive call. Which one?

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!