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.

Enter size: 3 Enter character: $ $$ Enter size: 4 Enter character: # ## $$$$$$$$ # # # # # # # # ****************
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
