QUESTION 1a A valid selection must be between 0 and 4. Enter the program below and complete
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 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;
}
Probability and Statistics for Engineers and Scientists
ISBN: 978-0495107576
3rd edition
Authors: Anthony Hayter