Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ exercise: In this exercise, you draw shapes. In particular, the V shape of varying sizes. Using a magnifying glass, you can see that everything

C++ exercise:

In this exercise, you draw shapes. In particular, the V shape of varying sizes. Using a magnifying glass, you can see that everything drawn on the computer screen is made from many small dots or pixels. Code was written to draw those pixels. You will write code to simulate the pixels needed to draw a V shape. For a pixel (picture element) use a single *, star, or asterix. You can develop your solution in steps:

1) Write code that displays a 7-line V shape on the screen. This can be done using a double-nested for-loop. The inner loop displays a line of star spaces star, one column (space ' ' or star *) at a time. The outer loop displays multiple lines, one row at a time. A 7-line V pattern can easily be done with 7 cout statements, but that is very limited and you cannot use this approach in the next step. Example: * * * * * * * * * * * * *

2) Instead of only making one V with exactly 7 lines, ask the user how many lines to make the V, then make the V-shape with the size desired. If the size requested is <=0, dont make a shape. See chapter 5, top of page 270 (8ed), page 271 (9ed), page 275 (10ed) for code that will loop using a for-loop. Position Vs to the left. Don't display unnecessary extra columns of spaces on the far left or right. The number of lines displayed for the V-shape should be exactly the number of lines requested - not one less, not one more.

3) It is tedious to use and test a program if it does one thing and stops. In this step, put the V-shape drawing code inside another loop. It is now triple-nested. The outer loop should repeatedly prompt the user for the number of lines to make the V. If the number is <= 0, quit. Otherwise, make a V pattern with the number of lines entered. Keep asking the user for the number of lines to draw, then draw a V shape, UNTIL the user wants to quit. A size of <=0 is a sentinel that means to quit. Tell the user how to quit! Display a blank line after each shape. Example: How many rows tall to draw a 'V'? (0 to quit): 1 *

How many rows tall to draw a 'V'? (0 to quit): 2 * * *

How many rows tall to draw a 'V'? (0 to quit): 3 * * * * *

How many rows tall to draw a 'V'? (0 to quit): 4 * * * * * * *

How many rows tall to draw a 'V'? (0 to quit): 0 Goodbye

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

Handbook Of Database Security Applications And Trends

Authors: Michael Gertz, Sushil Jajodia

1st Edition

1441943056, 978-1441943057

More Books

Students also viewed these Databases questions

Question

LO1 Understand risk management and identify its components.

Answered: 1 week ago