Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java program: public static String getFlag(int size, char color1, char color2, char color3) - This method returns a string where a triangle appears

Write a Java program: public static String getFlag(int size, char color1, char color2, char color3) - This method returns a string where a triangle appears on the left size of the diagram, followed by horizontal lines. For example, calling DrawingApp.getFlag(4, '*', 'B', 'G'); will generate the string:

*BBBBBBBBBBBBBBBBBBB **GGGGGGGGGGGGGGGGGG ***GGGGGGGGGGGGGGGGG ****BBBBBBBBBBBBBBBB ****BBBBBBBBBBBBBBBB ***GGGGGGGGGGGGGGGGG **GGGGGGGGGGGGGGGGGG *BBBBBBBBBBBBBBBBBBB

The diagram has a number of rows that corresponds to size * 2 and a number of colums that corresponds to size * 5. The first and last row will use color2 (except for the first character that will use color1). The center two rows will use color2 and the rest color3. The triangle will rely on color1 and will have a height corresponding to size * 2. If the size parameter is less than three, the method will return null and will not generate any diagram. For this method you can assume the colors are valid. The method MUST not rely on System.out.println().

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

Accounting And Auditing Research And Databases Practitioner's Desk Reference

Authors: Thomas R. Weirich, Natalie Tatiana Churyk, Thomas C. Pearson

1st Edition

1118334426, 978-1118334423

More Books

Students also viewed these Databases questions