8.9 Assignment 4
SUBMISSION: Electronically via myUnisa
Please note that we automatically give four days extension for this aassignment. It will be
to your own advantage to check after a few days whether the assignment has been registered
on the system. If you have not completed the assignment by the extension date, submit
whatever you have completed – you will get marks for everything that you have done.
If myUnisa is off-line when you want to submit the assignment, you need not contact us, because
we will be aware of it. Simply submit it as soon as myUnisa is available again.
DUE DATE 04 October 2021
UNIQUE NUMBER 862799
EXTENSION There is NO extension for this assignment.
TUTORIAL MATTER Study Guide, Lessons 24 –
CONTRIBUTION WEIGHT TO 20%
SEMESTER MARK
[85 Marks]
QUESTION 1: WHILE LOOP and SWITCH
An events ticket booking System prompts the user to make a choice as well as the number of tickets required. It
then displays the total cost of the order. The menu options and cost per ticket is as follows:
1 Exclusive VIP area A : R3 000.00
2 VIP area B : R2 000.00
3 Elevated area :R1200.00
4 General area R600.
0 QUIT
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;
52
, Question 1 a and b
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int 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 (selection<0 || selection > 4)
{
cout << "Invalid choice – Please re - enter ";
cin >> selection;
}
cout << "You have selected option number " << selection;
cout << "How many tickets would you like?" << endl;
int cost = 0;
int number;
cout << " Enter the number of tickets required ";
cin >> number;
switch (selection)
{
case 1: cost = number * 3000;
cout << "The total cost is R " << cost << endl;
break;
case 2: cost = number * 2000;
cout << "The total cost is R " << cost << endl;
break;
case 3: cost = number * 1200;
cout << "The total cost is R " << cost << endl;
break;
case 4: cost = number * 600;
cout << "The total cost is R " << cost << endl;
break;
case 0: cout << " Please come again" << endl;
break;
default:
cout << "Invalid selection";
cout << " Try again please" << endl;
}
system("Pause");
return 0;
}
SUBMISSION: Electronically via myUnisa
Please note that we automatically give four days extension for this aassignment. It will be
to your own advantage to check after a few days whether the assignment has been registered
on the system. If you have not completed the assignment by the extension date, submit
whatever you have completed – you will get marks for everything that you have done.
If myUnisa is off-line when you want to submit the assignment, you need not contact us, because
we will be aware of it. Simply submit it as soon as myUnisa is available again.
DUE DATE 04 October 2021
UNIQUE NUMBER 862799
EXTENSION There is NO extension for this assignment.
TUTORIAL MATTER Study Guide, Lessons 24 –
CONTRIBUTION WEIGHT TO 20%
SEMESTER MARK
[85 Marks]
QUESTION 1: WHILE LOOP and SWITCH
An events ticket booking System prompts the user to make a choice as well as the number of tickets required. It
then displays the total cost of the order. The menu options and cost per ticket is as follows:
1 Exclusive VIP area A : R3 000.00
2 VIP area B : R2 000.00
3 Elevated area :R1200.00
4 General area R600.
0 QUIT
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;
52
, Question 1 a and b
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int 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 (selection<0 || selection > 4)
{
cout << "Invalid choice – Please re - enter ";
cin >> selection;
}
cout << "You have selected option number " << selection;
cout << "How many tickets would you like?" << endl;
int cost = 0;
int number;
cout << " Enter the number of tickets required ";
cin >> number;
switch (selection)
{
case 1: cost = number * 3000;
cout << "The total cost is R " << cost << endl;
break;
case 2: cost = number * 2000;
cout << "The total cost is R " << cost << endl;
break;
case 3: cost = number * 1200;
cout << "The total cost is R " << cost << endl;
break;
case 4: cost = number * 600;
cout << "The total cost is R " << cost << endl;
break;
case 0: cout << " Please come again" << endl;
break;
default:
cout << "Invalid selection";
cout << " Try again please" << endl;
}
system("Pause");
return 0;
}