Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java program which implements both the while and for loop, as needed, to draw the illustrations given below. Shape 1: 123456789 12345678 1234567

Write a Java program which implements both the while and for loop, as needed, to draw the illustrations given below.

Shape 1:

123456789

12345678

1234567

123456

12345

1234

123

12

1

Shape 2:

*************

*************

*************

*************

*************

Shape 3:

============

* *

* *

* *

* *

* *

============

Hint: To draw the shapes above, you can use nested for loops to accomplish the task. The outer for loop iterates on each row, and the inner for loop iterates on each column of current row.

Shape 1 has 9 rows and column is decreasing on each row.

for (int row=0; row

{

for (int col=1; col<=rowSize-row; col++) //for each column on current row

{

//display col number with a space

}

// display a new line

}

Shape 2 has 5 rows, 13 columns.

for (int row=0; row

{

for (int col=0; col

{

//display

}

// display a new line

}

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

Database Processing Fundamentals Design And Implementation

Authors: KROENKE DAVID M.

1st Edition

8120322258, 978-8120322257

More Books

Students also viewed these Databases questions

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago