Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

LAB 4.4 - Working with if/else if Statements Step 1: Add the color.cpp program in your Lab4 folder to the project. Here is a

LAB 4.4 - Working with if/else if Statements Step 1: Add the color.cpp program in your Lab4 folder to theStep 2: Compile the program and then run it 5 times. For each run enter the menu choice shown in the table

LAB 4.4 - Working with if/else if Statements Step 1: Add the color.cpp program in your Lab4 folder to the project. Here is a copy of the source code. 1 // Lab 4 color.cpp 2 // This program lets the user select a primary color from a menu. 3 // PUT YOUR NAME HERE. 4 #include 5 #include 6 using namespace std; 7 8 int main() 9 { 10 int choice; should be 1, 2, or 3 11 12 13 // Display the menu of choices cout < < "Choose a primary color by entering its number. "; 14 < < "3 Yellow "; 15 16 17 18 19 picked 20 21 22 23 24 25 cout < < "1 Red " < < "2 Blue " 26 27 28 } // Menu choice // Get the user's choice cin >> choice; // Tell the user what he or she if (choice == 1) cout < < " You picked red. "; else if (choice == 2) cout < < " You picked blue. "; else yellow. "; cout < < " You picked return 0; Step 2: Compile the program and then run it 5 times. For each run enter the menu choice shown in the table below and write down the current output the program displays. Run output 1 2 3 4 5 Menu choice 1 2 3 0 99 New output Current Step 3: Improve the program so that only 1, 2, and 3 are accepted as valid choices. Make line 24 check for a choice of 3 before printing the message on line 25. Then add a trailing else that prints a descriptive error message whenever anything other than 1, 2, or 3 is entered. Step 4: Recompile the program and run it 5 more times, using the same 5 menu choices shown above. For each run, write wn the new output the program now displays.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Step 1 This program lets the user select a primary color from a menu include include using namespace ... 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_2

Step: 3

blur-text-image_3

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

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions

Question

=+b) Create a p chart for these samples.

Answered: 1 week ago

Question

Name two supply chain performance metrics and explain them.

Answered: 1 week ago

Question

Explain the importance of the purchasing function in organizations.

Answered: 1 week ago

Question

What is CPFR? What are its advantages and disadvantages?

Answered: 1 week ago