A concert hall has three seating categories: VVIP, VIP and GEN. Customers are allowed to book tickets to
attend any concerts that will be hosted in that hall using the price category as listed in Table 1. The
customers can book a minimum of 1 and a maximum of 10 tickets per category.
The manager wants a program that will allow him to sell tickets to the public and to calculate the revenue
he will get from selling the tickets in a day.
Table1:
Ticket Category Price Catergory
VVIP R3054.61
VIP R2095.51
GEN R1077.30
3.1 Create a C++ source file called TicketSales and save it in a file called TicketSales.cpp.
3.2 Create the following functions:
Functions:
Function Description Marks
3.2.1 validateInput() This function will receive two parameters that will consists of
the number of tickets and ticket category respectively.
This function must then determine and return results if the
number of tickets entered is valid as well as the catergory.
8
3.2.2 determineTicketPrice() This function will receive one parameter that will consists of
the ticket category.
The function must then determine and return the price for that
particular catergory using the information above
3.2.3 determineConcertPrice() This function will receive two parameters that will consists of
the number of tickets as well as the ticket price respectively.
This function must then calculate and return the amount due
for the concert. This amount must be inclusive of 15% vate
rate.
3
3.2.4 main() Add necessary pre-processor directives.
NB: The functions must be implemented above the main.
Declare all necessary constants and variables.
Prompt the user for the number of tickets he/she is
buying or a zero (0) to exit program.
#include <iostream>
#include <cstring>
using namespace std;
void validateInput (int ticketNumber, string ticketCategory) {
if (!(ticketNumber > 0 && ticketNumber <= 10)) {
cout << "You can book a minimum of 1 and a maximum of 10 tickets for per category.\nTry again.\n";
}
if (!(ticketCategory == "VVIP" || ticketCategory == "VIP" || ticketCategory == "GEN")) {
cout << "Please enter proper category name.\n";
}
}
float TicketPrice(string ticketCategory) {
float price;
if (ticketCategory == "VVIP") {
price = 3054.61;
}
if (ticketCategory == "VIP") {
price = 2095.51;
}
if (ticketCategory == "GEN") {
price = 1077.30;
}
return price;
}
float determineConcertPrice (int ticketNumber, float ticketPrice) {
// amount must be inclusive of 15% vate rate.
float ConcertPrice;
ConcertPrice = ticketNumber * ticketPrice * 1.15;
return ConcertPrice;
}
int main () {
int ticketNumber;
string ticketCategory;
float price, total_Price = 0;
while (true) {
cout << "Enter the number of tickets: "; cin >> ticketNumber;
cout << "Enter ticket category (ticketCategory must be uppercase): "; cin >> ticketCategory;
validateInput(ticketNumber, ticketCategory);
price = TicketPrice(ticketCategory);
total_Price += determineConcertPrice(ticketNumber, price);
if (ticketNumber == 0) {
break;
}
}
cout << "You must pay: " << total_Price;
}
Comments
Leave a comment