Question
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
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