Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm trying to figure out how to add below this following code the patterns that are given: System.out.println(); System.out.println(Class example ); for (int row =

I'm trying to figure out how to add below this following code the patterns that are given:

System.out.println();

System.out.println("Class example ");

for (int row = 1; row <= maxRows; row++) { starCnt = row; for (int star = 1; star <= starCnt; star++) { System.out.print("*"); } System.out.println(); }

Part 1- Pattern A Add code to your program to carry out pattern A as follows:

**********

*********

********

*******

******

*****

****

***

**

*

The leftmost stars are in the leftmost output column. Test your code with an odd number of stars and an even number of stars.

Part 2 -Pattern B Add code to your program to carry out pattern B as follows:

*

**

***

****

*****

******

*******

********

*********

**********

The leftmost star of the last row is in the first position of the output column. HINT: You used starCnt in the example pattern and pattern A. You should think about using a spaceCnt variable as well. Also, while developing the code, replace space which is "hidden", with another character which is visible. This will help you to see what is happening in the code.

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_2

Step: 3

blur-text-image_3

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

Data Analysis Using SQL And Excel

Authors: Gordon S Linoff

2nd Edition

111902143X, 9781119021438

More Books

Students also viewed these Databases questions

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago