Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java Help Triangle Pattern public static void triangle(int m, int n) // Precondi

ID: 3768869 • Letter: J

Question

Java Help

Triangle Pattern

public static void triangle(int m, int n)

// Precondition: m <= n
// 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:

*/

Explanation / Answer

#include using namespace std; void triangle(unsigned int m, unsigned int n); void sub1_rec(unsigned int m, unsigned int n); void sub2_rec(unsigned int m, unsigned int n); int main(){ int m,n; coutm>>n; triangle(m,n); } void triangle(unsigned int m, unsigned int n){ sub1_rec(m,n); sub2_rec(m,n); } void sub1_rec(unsigned int m, unsigned int n){ if (m==n){ for (int i=1;i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote