Question: Use nested for - loops to draw trapezoidal patterns using the $ character ( mountains of money ) . Here's a sample run of
Use nested forloops to draw trapezoidal patterns using the $ character mountains of money" Here's a sample run of your finished program:
Please enter the number of rows:
How many characters in the first row?
Here is your mountain of money:
$$$
$$$$$$$
$$$$$$$$$$$$
$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Your program will draw a money mountain of any size, limited only by the user's greed and the width of the output window. Here's how to
code it required: Declare three variables of type int: numRows, numChars and numSpaces. The first two variables will be initialized to the
corresponding user input. The third variable will have an initial value based on a simple calculation involving numRows. You figure out the
calculation. Your program will use three for loops: One outer loop with a number of iterations equal to numRows and two inner loops back
toback, not one inside the other to draw the leading spaces and the dollar signs for a given row. The number of leading spaces and the
number of dollar signs will be determined by the current values of numSpaces and numChars. That means those variables will need to be
updated at the bottom of your outer loop.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
