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