Question: QUESTION 1a A valid selection must be between 0 and 4. Enter the program below and complete the while loop. Name the program question1.cpp, compile

QUESTION 1a

A valid selection must be between 0 and 4. Enter the program below and complete the while loop. Name the program question1.cpp, compile and run it.
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
// Fill in the code to define an integer variable called selection
cout << "Please enter the choice of ticket "
<< "(a number from 1 to 4 or 0 to quit) " << endl;
cout << "Ticket Menu " << endl << endl;
cout << "1: Exclusive VIP area A " << endl;
cout << "2: VIP area B " << endl;
cout << "3: Elevated area " << endl;
cout << "4: General area R600 " << endl;
cout << "0: QUIT " << endl <<endl << endl;
cin >> selection ;
while (…………………) //complete the condition

{
cout << “Invalid choice – Please re-enter “;
cin >> selection;
}
cout << “You have selected option number “ << selection;
return 0;
}

QUESTION 1b

Modify question1.cpp by adding the code to calculate the cost per order. Make use of a switch statement.
cout << "You have selected option number "“ <<;
cout << "How many tickets would you like?" << endl;
// Fill in the code to read in number
// Fill in the code to begin a switch statement
// that is controlled by selection
{
case 1: cost = number * 3000;
cout << "The total cost is R " << cost << endl;
break;
// Fill in the code for the case VIP area B ( R2000.00 each)
// Fill in the code for the case Elevated area (R1200.00 each)
// Fill in the code for the case General area (R600.00 each)
case 0: cout << " Please come again" << endl;
break;
default:
cout << “Invalid selection”
cout << " Try again please" << endl;
}

Step by Step Solution

3.42 Rating (152 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Lets address each part of your question step by step QUESTION 1a Task You need to complete the code by defining an integer variable selection and a while loop condition to ensure the users input is va... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!