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
Max Function
Statistical function is of many categories. One of them is a MAX function. The MAX function returns the largest value from the list of arguments passed to it. MAX function always ignores the empty cells when performing the calculation.
Power Function
A power function is a type of single-term function. Its definition states that it is a variable containing a base value raised to a constant value acting as an exponent. This variable may also have a coefficient. For instance, the area of a circle can be given as:
In C++ use if-else blocks and play loop for this
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.
Step by step
Solved in 3 steps with 1 images