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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started