Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This question was asked during my exam. Can you please tell me the solution in both ways with more than one nested loop and with

This question was asked during my exam. Can you please tell me the solution in both ways with more than one nested loop and with just one nested loop.

Write a class TwoDimensionalArray with a main method that fills a two-dimensional array with asterisks '*'.

The program creates one n x n two-dimensional array of char. The value of n is read from the user. The program fills the two-dimensional array with asterisks to represent a right triangle. Its right angle should be placed at the bottom right as shown below. With n, each of the sides should consist of n asterisks. The program also prints the content of the two dimensional array as an output. It should work with any integer value of n. You have to use nested-for loops to fill and print the array for credit. You are allowed to use multiple nested for loops to solve the problem.

Extra credit (2 points): If you solve this problem using only one nested for loop, 2 points of extra credit will be given.

Here are the expected outputs with n = 5 and n = 6, respectively.

image text in transcribed image text in transcribed

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 Security XI Status And Prospects

Authors: T.Y. Lin, Shelly Qian

1st Edition

0412820900, 978-0412820908

More Books

Students also viewed these Databases questions

Question

1. Write down two or three of your greatest strengths.

Answered: 1 week ago