Question: Q2: [Programming Style and Basic Programming] (25%) Generate a tree controlled by one positive integer (int-type) input N (N > 0) as follows: * The

 Q2: [Programming Style and Basic Programming] (25%) Generate a tree controlledby one positive integer (int-type) input N (N > 0) as follows:

Q2: [Programming Style and Basic Programming] (25%) Generate a tree controlled by one positive integer (int-type) input N (N > 0) as follows: * The number of triangles in the tree is N, e.g., N is 2 in the table below. The number of rows of the i-th. triangle is i + 1, e.g., the first ({ = 1) triangle in the table below has 2 (= 1 + 1) rows. The number of asterisks ("*") in each row is 1, 3,5, ..., 2xk - 1, where & is the k-th, row of one triangle. Beneath the last triangle, there is a trunk, which is along the center line of the tree. The height (number of rows) of the trunk is also N, e.g., this height is 2 in the table below. # Implement Q2 () with the following notes: The input should be checked and the user needs to input again if an invalid input is detected. . There is no space between two consecutive asterisks ("*") on the same row. There is no space before the first asterisk on the last row of the last triangle. Examples 1 (The input value is underlined); Please input the integer N: 3Examples 2 (The input values are underlined): Please input the integer N: -2 Please input the integer N: -1 Please input the integer N: Please input the integer N: 2

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 Programming Questions!