Question: Write a Java program that prints a triangle where each row has twice as many characters as the preceding one. The first row will have

Write a Java program that prints a triangle where each row has twice as many characters as the preceding one. The first row will have 2 characters. The program will read the size (an integer value) of the triangle and a character. It will then generate a triangle with a number of rows that corresponds to size and where the character provided is used for odd-numbered rows. Even-numbered rows will always use a *. We use the message Enter size: and Enter character: to read data. Use the Scanner class to read data. Below we have provided two examples of running the program. Notice your program must work for other values. Underlined text represent input provided by the user.

Write a Java program that prints a triangle where each row has

Enter size: 3 Enter character: $ $$ Enter size: 4 Enter character: # ## $$$$$$$$ # # # # # # # # ****************

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!