Green            10      Bright Green 3                 Cyan              11      Bright Cyan 4                 Red               12       Bright Red 5                 Purple           13       Bright Purple 6                 Yellow           14       Bright Yellow 7                 White            15       Bright White Write a C++ program that asks the user to select a color and a shape to draw.   In main, begin by declaring variables and

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

In C++ use if-else blocks and play loop for this program

Number    Text Color    Number    Text Color
0                 Black               8      Bright Black
1                 Blue                 9      Bright Blue
2                 Green            10      Bright Green
3                 Cyan              11      Bright Cyan
4                 Red               12       Bright Red
5                 Purple           13       Bright Purple
6                 Yellow           14       Bright Yellow
7                 White            15       Bright White


Write a C++ program that asks the user to select a color and a shape to draw.  

In main, begin by declaring variables and displaying the class header, and cout an explanation of the program.  You may include this in your header or make it separate.  

You will need constants for the maximum color number and for the maximum picture number as well as a value that indicates the user has finished drawing. 
These will look like:
//Constants
const int QUIT{ 6}; 
const int MAX_COLORS{ 6};
const int MAX_PIX{3};

At this point, create a handle to the standard output device (the console)  using:
HANDLE screen = GetStdHandle(STD_OUTPUT_HANDLE);
You will use this handle to access the screen to change colors.  You will also need to #include <windows.h>.

Open a do-while loop.  This is the “play loop.”  Provide a menu of colors and ask the user to select a color for the drawing.  There will be 6 menu items, 5 colors, blue, green, cyan, red and purple.  These will be selections 1-5.  Selection 6 is to quit the drawing loop.  

Use a while loop to check to make sure that the user’s answer is in the correct range of value, 1 – 6.  If it is not, loop back and ask the user to re-enter their choice.

As long as the selection is not 6, present another menu and ask the user to select the picture to be drawn.  There will be 3 pictures, a 1) smiling face, 2) a pyramid and 3) a picture of your choice.  Check the input validity of that selection using a do while loop.

Use a switch structure to process the picture selection.  Declare any variables you will use in the drawings up above the switch statement.   

In each case statement, set the color using:
SetConsoleTextAttribute(screen, colorChoice);

Be sure to adjust the colorChoice value so that you will be drawing with the bright version of the color.  It shows up so much better!  Each picture will be drawn using the color selected by the user.  Each picture can be drawn using symbols of your choice.  

When the user selects 6 for the color selection, drop out of the loop, and show a good-bye message.

 

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education