Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed

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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL Crash Course A Hands On Introduction To Database Development

Authors: Rick Silva

1st Edition

1718503008, 978-1718503007

More Books

Students also viewed these Databases questions