Assignment
Faculty : Faculty of Computing And
Information Technology
Course Code & Title BACS1014 Problem Solving and
: Programming
Student Name : 1. BEH GUO HAO
2. BENEDICT YAP ZHENG-YI
Student ID : 1. 20WMR13091
2. 20WMR11830
Class : RSD1S2G2
Programme : RSD
Declaration of Originality
Declaration of Originality
I declare that this assignment is free from all forms of plagiarism
and for all intents and purposes is my own work. I understand
that I will be penalized if I have not complied with TAR UC’s
Plagiarism policy.
Signature: BGH Name: Beh Guo Hao _ Date: 7/4/2021 _
Declaration of Originality
I declare that this assignment is free from all forms of plagiarism
and for all intents and purposes is my own work. I understand
that I will be penalized if I have not complied with TAR UC’s
Plagiarism policy.
Signature: _ YAP Name: Benedict Yap Zheng-Yi _ Date: 7/4/2021 _
Table of Contents
No. Title Page
1 Brief Description / Purpose 1
2 Overall Program Design 2
3 Method of Solution 3-13
4 Added features 14
5 Program Testing & Outputs 15-48
6 Constants & variables 49-52
7 Program Listing 53-80
Brief Description / Purpose
A bus company needs to efficiently issue tickets to customers based on their
chosen journey and to keep records of the different information given by the
customer. Thus, we have developed a simple Bus Ticketing System that will enable
the bus company to issue tickets to the customers quickly, and at the end of the day
produce a Daily Sales Report.
1
Overall Program Design
Based on the requirement of the bus company, we have developed a user
friendly bus ticketing system for them. From the perspective of UI/UX, we can see the
simplicity of the bus logo design and the ease of use in the bus ticketing system. In the
bus ticketing system, the user just have to enter the option provided to pick their
desired details of the bus so they no longer need to write any word to tell about the
details they wanted. Other than that, we have implemented two types of payment
method which is by cash or by credit card. This will help a lot for those customer who
preferred to pay by cash and also who like to pay cashless. Moreover, we also added a
promo code system inside the bus ticketing system whereby the customer can enter a
valid promo code to get their bus ticket with a discounted price. Therefore, we believe
that the bus ticketing system will helps the bus company to gain more ticket sales and
increase their entrepreneurial savvy.
2
Method of Solution
Structure Chart
3
Flow Chart
4
5
6
7
8
9
1
1
1
1
Added Features
No. Extra features Description
1. Payment method We have added 2 types of payment methods which is
cash and credit card. We believe that one of the
reason that causes the sales of bus company dropped
could because of the customer complaining about
lack of choice in paying bus ticket. Since we are
encourage to go cashless so we think adding another
choice of payment will be a convenient and better
solution.
2. Promo code system We noticed that the price of the bus ticket is quite
over average so we decided to give some discount
every month on the bus ticket for those who applied
the promo code before payment made. Thus, we have
added a promo code system in the bus ticketing
system which would help increase the sales of the
bus ticket.
1
Program Testing & Outputs
First Set (1st customer)
No. Test Data (Input) Expected Output
1. 1 Proceed to show bus schedule and enter destination
2. 1 Proceed to select departure day and date
3. 1 Proceed to select departure time
4. 1 Proceed to select bus type
5. a Proceed to enter amount of person boarding the bus
6. 2 Proceed to enter ticket quantity
7. 1 Proceed to ask having promo code or not
8. 1 Proceed to enter promo code
9. gogoBus Print “Congrats! Promo code applied successfully. (15%
off bus ticket)”
Press any key to continue…
10. random key Print bus ticket details and proceed to ask whether want
to purchase multiple bus ticket
11. 2 Proceed to payment gateway and ask for payment
method
12. 1 Proceed to enter amount of cash
13. 100 Print total price, paid amount and balance of change
Display ending message
Press any key to continue…
14. random key Back to main menu
1
1
1
1
1
2
2
Second Set (2nd customer)
No. Test Data (Input) Expected Output
1. 1 Proceed to show bus schedule and enter destination
2. 2 Proceed to select departure day and date
3. 1 Proceed to select departure time
4. 2 Proceed to select bus type
5. b Sorry, we have only one bus type for the selected
departure time.
Back to select bus type
6. a Proceed to enter amount of person boarding the bus
7. 0 Amount entered cannot be 0. Please try again.
Back to enter amount of person boarding the bus
8. 3 Proceed to enter ticket quantity
9. 0 Ticket quantity cannot be 0. Please try again.
Back to enter ticket quantity
10. 2 Proceed to ask having promo code or not
11. 2 Press any key to continue . . .
12. Random key Print bus ticket details and proceed to ask whether want
to purchase multiple bus ticket
13. 1 Back to show bus schedule and enter destination
14. penang Invalid input! Please try again.
Back to enter destination
15. 2 Proceed to select departure day and date
16. 1 Sorry, you cannot buy a ticket to any other trip on the
same date.
Back to enter destination
17. 2 Proceed to select departure day and date
2
18. 2 Proceed to select departure time
19. 1 Proceed to select bus type
20. a Proceed to enter amount of person boarding the bus
21. 1 Proceed to enter ticket quantity
22. 1 Proceed to ask having promo code or not
23. 1 Proceed to enter promo code
24. gogoBus Sorry, promo code entered only applied for 2 or more
person.
Back to enter promo code
25. FNSbus Print “Congrats! Promo code applied successfully. (10%
off bus ticket)”
Press any key to continue…
26. Random key Print bus ticket details and proceed to ask whether want
to purchase multiple bus ticket
27. 2 Proceed to payment gateway and ask for payment
method
28. 2 Proceed to enter credit card number
29. 233455667 Proceed to enter pin
30. 123456 Processing......Done.
Print total price, paid amount and balance of change
Display ending message
Press any key to continue…
31. Random key Back to main menu
2
2
2
2
2
2
2
3
3
3
3
Third Set (3rd customer)
No. Test Data (Input) Expected Output
1. a Invalid input! Please try again.
Back to enter choice
2. 1 Proceed to show bus schedule and enter destination
3. 1 Proceed to select departure day and date
4. 2 Proceed to select departure time
5. abc Invalid input! Please try again.
Back to select departure time
6. 1 Proceed to select bus type
7. a Proceed to enter amount of person boarding the bus
8. 2 Proceed to enter ticket quantity
9. 2 Proceed to ask having promo code or not
10. 1 Proceed to enter promo code
11. 123abc Invalid promo code! Please try again.
Back to enter promo code
12. gogoBus Print “Congrats! Promo code applied successfully. (15%
off bus ticket)”
Press any key to continue . . .
13. Random key Print bus ticket details and proceed to ask whether want
to purchase multiple bus ticket
14. No Invalid input. Please try again.
Back to ask whether want to purchase multiple bus ticket
15. 2 Proceed to payment gateway and ask for payment
method
16. 1 Proceed to enter amount of cash
17. 200 Sorry, cash amount is insufficient. Please try again.
3
Back to enter amount of cash
18. 300 Print total price, paid amount and balance of change
Display ending message
Press any key to continue…
19. Random key Back to main menu
3
3
3
3
3
4
4
Forth Set (Choices in main menu)
No. Test Data (Input) Expected Output
1. 1 Ticket purchase (tested in first to forth set)
2. 2 Promo code
Display available promo code to the customer and other
information about promo code
Press any key to continue . . .
3. 3 Daily sales report
Display the total number of customers for the day, the
breakdown of ticket sales by destination, dates of trips
bought, and the bus types chosen.
Lastly, display the quantity of tickets sold, amounts
charged, total discounts and total amounts paid.
Press any key to continue . . .
4. 4 Exit the bus ticketing system and display ending message
4
4
4
4
4
4
4
Constants & variables
Global variable
const double procFee = 0.06;
int p = 0, n = 0, pax[50], ticket[50], sumTicket, cont;
double subTotal[50], sumTotal, price, feeCharge[50],
finalBill[50], sumCharge, disC, totalDis[50], sumDis,
totMulBill;
string bDes[50], bDate[50], bTime[50], bType[50], desArr[50],
dateArr[50], code;
string promoCode[] = { "FNSbus", "gogoBus" };
bool getDis[50] = { false };
Local variable
int choice;
string star =
"*************************************************************
*******\n";
char des, date, time;
char type;
char method;
double pay, balance;
int ccNum, pin;
char c;
4
Constant
Data type Value Purpose
const double procFee = 0.06 A constant double value of processing
fee to be calculate when making
payment for bus ticket.
Variable
Data type Identifier/Value Purpose
int p = 0 Act as a counter and to be plus one for
every next purchase.
int n = 0 Act as a counter and to be plus one for
same customer to make multiple
purchase of bus ticket.
int pax[50] An integer array to store amount of
person for every purchase up to 50
times
int ticket[50] An integer array to store amount of
ticket for every purchase up to 50
times
int sumTicket A variable to store total quantity of
ticket sold
int cont A variable to get user input to check
whether the customer want to continue
purchase multiple ticket
double subTotal[50] An array to store subtotal of ticket
price for every purchase up to 50 times
double sumTotal A variable to store total daily sales
double price Assign value to it when user select the
bus type according to its price and use
it to calculate when make payment
double feeCharge[50] An array to store charges of
5
processing fee
double finalBill[50] An array to store final total bill that to
be pay by the customer
double sumCharge A variable to store total sum up of
charges of daily sales
double disC A variable that will change value
according to promo code entered by
the customer
double totalDis[50] An array to store discounted amount of
every purchase
double sumDis A variable to sum up total discount
amount of daily sales
double totMulBill A variable to sum up total bill of
multiple purchase
string bDes[50] An array to store destination selected
by the customer
string bDate[50] An array to store destination selected
by the customer
string bTime[50] An array to store time selected by the
customer
string bType[50] An array to store bus type selected by
the customer
string desArr[50] An array to store the first selected
destination by the same customer when
the customer want to purchase multiple
bus ticket
string dateArr[50] An array to store the first selected date
by the same customer when the
customer want to purchase multiple
bus ticket
string code A variable to get the input of promo
code
string promoCode[] = { An array to store valid promo code
"FNSbus",
5
"gogoBus" }
bool getDis[50] = { An array that store boolean value to
false } check whether the user enter a valid
promo code
int choice Stores the number of the option chosen
by the user in the switch
string star Store a line of asterisk for reuse
purposes in designing the bus schedule
char des Stores the destination which was
chosen by the user
char date Stores the date which was chosen by
the user
char time Stores the time which was chosen by
the user
char type Stores the type of bus which was
chosen by the user
char method Stores the payment method which was
chosen by the user
double pay Stores the number of payment that user
insert
double balance Stores the number when pay minus bill
int ccNum Stores the credit card number that user
insert
int pin Stores the pin number that user insert
char c Stores the selection Yes or NO which
was chosen by the user
5
Program Listing
#include <iostream>
#include <string>
#include <iomanip>
#include <cctype>
using namespace std;
//prototype
void logo();
void bus_schedule();
void purchase_process();
void validate(char input);
void bus_type(char date, char time);
void print_bill(int pax);
void multi_purchase();
void payment(double totBill);
void sales_detail();
void discount();
void promo_code();
//global variable
const double procFee = 0.06;
int p = 0, n = 0, pax[50], ticket[50], sumTicket, cont;
double subTotal[50], sumTotal, price, feeCharge[50],
finalBill[50], sumCharge, disC, totalDis[50], sumDis,
totMulBill;
string bDes[50], bDate[50], bTime[50], bType[50], desArr[50],
dateArr[50], code;
string promoCode[] = { "FNSbus", "gogoBus" };
5
bool getDis[50] = { false };
int main()
int choice;
do {
//Display logo and menu
logo();
cout << "\t1 => Ticket Purchase\n\t2 => Promo
Code\n\t3 => Daily Sales Report\n\t4 => Exit";
menu:
cout << "\n\nEnter your choice: ";
while (!(cin >> choice)) //validate for wrong data
type input
cout << "\nInvalid input! Please try again."
<< endl;
cin.clear();
cin.ignore(100, '\n');
goto menu;
switch (choice) {
case 1:
cin.ignore(100, '\n'); //make sure choice
accept 1 character only
system("CLS"); //clear screen
start:
5
bus_schedule();
purchase_process();
discount();
print_bill(pax[p]);
multi_purchase();
p++; //count adding for new purchase
if (cont == 1)
goto start;
payment(totMulBill);
totMulBill = 0; //reset the total multiple
bill after payment made
system("PAUSE");
system("CLS");
break;
case 2:
cin.ignore(100, '\n'); //make sure choice
accept 1 character only
system("CLS");
promo_code();
break;
case 3:
cin.ignore(100, '\n'); //make sure choice
accept 1 character only
system("CLS");
sales_detail();
break;
case 4: cout << "\n******** Thank you for using our
bus ticketing system!! ********" << endl;
5
break;
default:
cout << "\nInvalid input! Please try again."
<< endl;
goto menu;
} while (choice != 4);
system("pause>0");
void logo()
cout << " .----------------------------------------------
---------------. \n";
cout << " '------..-------------..----------..----------
..---------..--.| \n";
cout << " | \\ || ||
|| || || \n";
cout << " | \\ || ||
|| || || \n";
cout << " | \\ || ||
|| || || \n";
cout << " | .. || _ _ || _ _ || _ _
|| _ _ || || \n";
cout << " | || || // // || // // || // //
|| // // || /|| \n";
cout << " |_.------''----------''----------''----------
''----------''--'| \n";
cout << " |)| | | | | |
F&S| ||==| | \n";
cout << " | | | _-_ | | | | .-.
| ||==| C| \n";
5
cout << " | | __ |' . . '| __ | __ | | ' . . '
| ___ | '__==' \n";
cout << " '-------'| ( ) |'---------------------'| ( )
|'--------'' \n";
cout << " '._.' '._.'
\n\n";
cout << "\t=======================================\n";
cout << "\t| FAST AND SAFE BUS |\n";
cout << "\t=======================================\n\n";
cout << "\t>>Welcome to F&S Bus Ticketing System<<\n\n";
void bus_schedule()
string star =
"*************************************************************
*******\n";
cout << "From Kuala Lumpur to Johor Bahru\n";
cout << star;
cout << "| Day & Date | Departure Time | Bus Type |
Price per pax (in RM) |\n";
cout << star;
cout << "| Monday, 25 | 0800 | Standard |
40 |\n";
cout << "| January 2021 | | |
|\n";
cout << star;
cout << "| | 1400 | Premium |
70 |\n";
5
cout << star;
cout << "| | | |
|\n";
cout << star;
cout << "| Thursday, 28 | 1100 | Premium |
70 |\n";
cout << "| January 2021 | | |
|\n";
cout << star;
cout << "| | 1600 | Standard |
40 |\n";
cout << star;
cout << "\n\nFrom Kuala Lumpur to Penang\n";
cout << star;
cout << "| Day & Date | Departure Time | Bus Type |
Price per pax (in RM) |\n";
cout << star;
cout << "| Tuesday, 26 | 0900 | Standard |
50 |\n";
cout << "| January 2021 | | |
|\n";
cout << star;
cout << "| | 1800 | Premium |
95 |\n";
cout << star;
cout << "| | | |
|\n";
cout << star;
cout << "| Friday, 29 | 1500 | Premium |
100 |\n";
cout << "| January 2021 | | |
|\n";
5
cout << star << endl << endl;
void purchase_process()
char des, date, time;
destination:
cout << "\n1. Johor Bahru\n2. Penang\nPlease enter your
destination > ";
cin >> des;
cin.ignore(100, '\n');
if (des == '1') {
bDes[p] = "Johor Bahru";
day_date_1:
cout << "\n1. Monday 25/01/2021\n2. Thursday
28/01/2021\nPlease enter departure day and date > ";
cin >> date;
cin.ignore(100, '\n');
do { //repeat if wrong input
if (date == '1')
bDate[p] = "Monday, 25 January 2021";
//checking if same user is buying same
date to other trip
for (int i = 0; i < n; i++)
5
{
if (bDes[p] == desArr[i] &&
bDate[p] == dateArr[i])
cout << "\nSorry, you cannot
buy a ticket to any other trip on the same date.\n";
goto destination;
cout << "\n1. 0800\n2. 1400\n";
else if (date == '2')
bDate[p] = "Thursday, 28 January 2021";
//checking if same user is buying same
date to other trip
for (int i = 0; i < n; i++)
if (bDes[p] == desArr[i] &&
bDate[p] == dateArr[i])
cout << "\nSorry, you cannot
buy a ticket to any other trip on the same date.\n";
goto destination;
cout << "\n1. 1100\n2. 1600\n";
else
6
validate(date);
goto day_date_1;
cout << "Please enter departure time > ";
cin >> time;
cin.ignore(100, '\n');
validate(time);
//assign ticket data from user selection
if (date == '1' && time == '1')
bTime[p] = "0800";
bType[p] = "Standard";
else if (date == '1' && time == '2')
bTime[p] = "1400";
bType[p] = "Premium";
else if (date == '2' && time == '1')
bTime[p] = "1100";
bType[p] = "Premium";
else
bTime[p] = "1600";
bType[p] = "Standard";
6
}
if (date == '1' && time == '1' || date == '2'
&& time == '2')
price = 40;
else
price = 70;
} while (time != '1' && time != '2');
else if (des == '2')
bDes[p] = "Penang";
day_date_2:
cout << "\n1. Tuesday 26/01/2021\n2. Friday,
29/01/2021\nPlease enter departure day and date > ";
cin >> date;
cin.ignore(100, '\n');
do { //repeat if wrong input
if (date == '1')
bDate[p] = "Tuesday, 26 January 2021";
//checking if same user is buying same
date to other trip
for (int i = 0; i < n; i++)
6
if (bDes[p] == desArr[i] &&
bDate[p] == dateArr[i])
cout << "\nSorry, you cannot
buy a ticket to any other trip on the same date.\n";
goto destination;
cout << "\n1. 0900\n2. 1800\n";
else if (date == '2')
bDate[p] = "Friday, 29 January 2021";
//checking if same user is buying same
date to other trip
for (int i = 0; i < n; i++)
if (bDes[p] == desArr[i] &&
bDate[p] == dateArr[i])
cout << "\nSorry, you cannot
buy a ticket to any other trip on the same date.\n";
goto destination;
date_2_time:
cout << "\n1. 1500\n";
else
6
validate(date);
goto day_date_2;
cout << "Please enter departure time > ";
cin >> time;
cin.ignore(100, '\n');
validate(time);
//assign ticket data from user selection
if (date == '1' && time == '1')
bTime[p] = "0900";
bType[p] = "Standard";
else if (date == '1' && time == '2')
bTime[p] = "1800";
bType[p] = "Premium";
else
bTime[p] = "1500";
bType[p] = "Premium";
if (date == '2' && time == '2')
6
cout << "\nInvalid input! Please try
again!\n" << endl;
goto date_2_time;
if (date == '1' && time == '1')
price = 50;
else if (date == '1' && time == '2')
price = 95;
else
price = 100;
} while (time != '1' && time != '2');
else
validate(des);
goto destination;
bus_type(date, time);
do {
cout << "\nPlease enter amount of person boarding
the bus > ";
while (!(cin >> pax[p])) //validate for wrong data
type input
cout << "\nInvalid input. Please try
again.\n";
6
cout << "\nPlease enter amount of person
boarding the bus > ";
cin.clear();
cin.ignore(100, '\n');
if (pax[p] == 0)
cout << "\nAmount entered cannot be 0. Please
try again.\n";
} while (pax[p] == 0);
do {
cout << "\nPlease enter ticket quantity > ";
while (!(cin >> ticket[p])) //validate for wrong
data type input
cout << "\nInvalid input. Please try
again.\n";
cout << "\nPlease enter ticket amount > ";
cin.clear();
cin.ignore(100, '\n');
if (ticket[p] == 0)
cout << "\nTicket quantity cannot be 0. Please
try again.\n";
} while (ticket[p] == 0);
void validate(char input) //validate data input and print
error message
6
if (input != '1' && input != '2' || !isdigit(input))
cout << "\nInvalid input! Please try again.\n" <<
endl;
void bus_type(char date, char time)
char type;
do {
if (date == '1')
if (time == '1')
cout << "\nA. Standard\n";
else
cout << "\nA. Premium\n";
else
if (time == '1')
cout << "\nA. Premium\n";
else
cout << "\nA. Standard\n";
cout << "Please enter bus type > ";
cin >> type;
cin.ignore(100, '\n');
6
type = toupper(type);
if (type != 'A') //checking for wrong input
cout << "\nSorry, we have only one bus type
for the selected departure time.\n";
} while (type != 'A');
void print_bill(int pax)
//Bill calculation
subTotal[p] = pax * price * ticket[p];
feeCharge[p] = subTotal[p] * procFee;
if (getDis[p]) {
if (code == "gogoBus")
disC = 0.85;
totalDis[p] = (subTotal[p] + feeCharge[p]) *
0.15;
if (code == "FNSbus")
disC = 0.9;
totalDis[p] = (subTotal[p] + feeCharge[p]) *
0.1;
finalBill[p] = (subTotal[p] + feeCharge[p]) * disC;
6
else {
finalBill[p] = subTotal[p] + feeCharge[p];
totMulBill += finalBill[p];
//print bill detail
cout << "\t=====================================\n";
cout << "\t| F&S BUS Ticket |\n";
cout << "\t=====================================\n\n";
cout << "\tFrom kuala Lumpur to " << bDes[p] << endl;
cout << "\t-------------------------------------------
\n";
cout << "\tDay and Date\t: " << bDate[p] << endl;
cout << "\tTime\t\t: " << bTime[p] << endl;
cout << "\tBus type\t: " << bType[p] << endl;
cout << "\tPrice\t\t: RM " << price << endl;
cout << "\tPax\t\t: " << pax << endl;
cout << "\tTicket amount\t: " << ticket[p] << endl;
cout << "\t-------------------------------------------
\n";
cout << "\tSubtotal\t: RM " << setprecision(2) << fixed
<< showpoint << subTotal[p] << endl;
cout << "\tProcessing fee\t: 6% " << endl;
if (getDis[p])
if (code == "gogoBus")
cout << "\tDiscount(s)\t: -15%" << endl;
if (code == "FNSbus")
cout << "\tDiscount(s)\t: -10%" << endl;
6
}
else {
cout << "\tDiscount(s)\t: -" << endl;
cout << "\tTotal amount\t: RM " << setprecision(2) <<
fixed << showpoint << finalBill[p] << endl;
void multi_purchase()
again:
cout << "\n1. Yes\n2. No\nDo you want to purchase
multiple bus ticket? > ";
while (!(cin >> cont)) //validate for wrong data type
input
cout << "\nInvalid input. Please try again.\n";
cout << "\n1. Yes\n2. No\nWould you like to continue
our bus ticketing system? > ";
cin.clear();
cin.ignore(100, '\n');
if (cont == 1) // store the destination and time to check
if the user pick the same date to other trip
desArr[n] = bDes[p];
dateArr[n] = bDate[p];
n++; //count adding for next continue purchase
7
else if (cont == 2) //reset the data stored in array for
next customer
for (int i = 0; i <= n; i++) {
desArr[i].clear();
dateArr[i].clear();
n = 0;
else
cout << "\nInvalid input. Please try again.\n";
goto again;
system("CLS");
void payment(double bill)
char method;
double pay, balance;
int ccNum, pin;
cout << "\t=====================================\n";
cout << "\t| Payment Gateway |\n";
cout << "\t=====================================\n\n";
7
cout << "\tTotal amount to pay\t: RM " << setprecision(2)
<< fixed << showpoint << bill << endl;
payment_method:
cout << "\nHow would you like to pay the bus ticket
with?\n1. Cash\n2. Credit Card\n";
cout << "Enter > ";
cin >> method;
cin.ignore(100, '\n');
if (method == '1')
cash:
cout << "\nPlease enter the amount of cash you
wanted to pay > RM ";
while (!(cin >> pay)) //validate for wrong data type
input
cout << "\nInvalid input! Please try
again.\n";
cout << "\nPlease enter the amount of cash you
wanted to pay > RM ";
cin.clear();
cin.ignore(100, '\n');
if (pay >= bill)
balance = pay - bill;
else
7
cout << "\nSorry, cash amount is insufficient.
Please try again.\n";
goto cash;
else if (method == '2')
cout << "\nPlease enter your credit card number > ";
while (!(cin >> ccNum)) //validate for wrong data
type input
cout << "\nInvalid credit card number! Please
try again.\n";
cout << "\nPlease enter your credit card
number > ";
cin.clear();
cin.ignore(100, '\n');
cout << "Pin > ";
while (!(cin >> pin)) //validate for wrong data type
input
cout << "\nInvalid pin number! Please try
again.\n";
cout << "\nPin > ";
cin.clear();
cin.ignore(100, '\n');
7
pay = bill;
balance = 0;
cout << "\n\nProcessing......Done.\n";
else
validate(method);
goto payment_method;
//Display payment made detail
cout << "\nTotal\t\t\t: RM " << setprecision(2) << fixed
<< showpoint << bill;
cout << "\n--------------------------------------";
cout << "\nPaid\t\t\t: RM " << setprecision(2) << fixed
<< showpoint << pay;
cout << "\nBalance of change\t: RM " << setprecision(2)
<< fixed << showpoint << balance << endl << endl;
cout << "\n************ Thank you, have a nice trip!!
************\n" << endl;
void sales_detail()
cout << "\t=====================================\n";
cout << "\t| Daily Sales Report |\n";
cout << "\t=====================================\n\n";
for (int i = 0; i < p; i++)
7
cout.setf(ios::right, ios::adjustfield);
cout.width(20);
cout << "Destination: " << bDes[i] << endl;
cout.setf(ios::right, ios::adjustfield);
cout.width(20);
cout << "Day & Date: " << bDate[i] << endl;
cout.setf(ios::right, ios::adjustfield);
cout.width(20);
cout << "Time: " << bTime[i] << endl;
cout.setf(ios::right, ios::adjustfield);
cout.width(20);
cout << "Bus type: " << bType[i] << endl;
cout.setf(ios::right, ios::adjustfield);
cout.width(20);
cout << "Pax: " << pax[i] << endl;
cout.setf(ios::right, ios::adjustfield);
cout.width(20);
cout << "Ticket quantity: " << ticket[i] << endl;
cout.setf(ios::right, ios::adjustfield);
cout.width(20);
cout << "Subtotal: ";
cout << "RM " << subTotal[i] << endl;
7
cout.setf(ios::right, ios::adjustfield);
cout.width(20);
cout << "Processing fee: ";
cout << "RM " << setprecision(2) << fixed <<
showpoint << feeCharge[i] << endl;
if (getDis[i]) {
cout.setf(ios::right, ios::adjustfield);
cout.width(20);
cout << "Discount: ";
cout << "RM " << setprecision(2) << fixed <<
showpoint << totalDis[i] << endl;
else {
cout.setf(ios::right, ios::adjustfield);
cout.width(20);
cout << "Discount: ";
cout << " - " << endl;
cout.setf(ios::right, ios::adjustfield);
cout.width(20);
cout << "Total amount: ";
cout << "RM " << setprecision(2) << fixed <<
showpoint << finalBill[i] << endl;
cout << "-------------------------------------------
------------" << endl;
//sum up total sales
sumTicket += ticket[i];
7
sumTotal += finalBill[i];
sumCharge += feeCharge[i];
sumDis += totalDis[i];
cout << endl << endl;
cout << "Total quantity of tickets sold\t\t: " <<
sumTicket << endl;
cout << "Total amounts charged (Processing fee)\t: RM "
<< setprecision(2) << fixed << showpoint << sumCharge << endl;
cout << "Total discounts (Promo code applied)\t: RM " <<
setprecision(2) << fixed << showpoint << sumDis << endl;
cout << "Total sales for today\t\t\t: RM " <<
setprecision(2) << fixed << showpoint << sumTotal << endl <<
endl;
system("PAUSE");
system("CLS");
void discount()
char c;
discount:
cout << "\nDo you have any promo code?\n1. Yes\n2. No\n";
cout << "Enter > ";
cin >> c;
cin.ignore(100, '\n');
if (c == '1')
7
do {
cout << "\nEnter promo code : ";
cin >> code;
//check for valid promo code entered
for (int i = 0; i < size(promoCode); i++)
if (code == promoCode[i])
getDis[p] = true;
if (getDis[p])
if (code == "gogoBus" && pax[p] >= 2)
cout << "\nCongrats! Promo code
applied successfully. (15% off bus ticket)\n\n";
else if (code == "FNSbus")
cout << "\nCongrats! Promo code
applied successfully. (10% off bus ticket)\n\n";
else
cout << "\nSorry, promo code
entered only applied for 2 or more person.\n";
getDis[p] = false;
7
}
else
cout << "\nInvalid promo code! Please try
again.\n";
} while (!getDis[p]);
else if (c == '2') {
getDis[p] = false;
cout << endl;
else {
validate(c);
goto discount;
system("PAUSE");
system("CLS");
void promo_code()
cout << "\t=====================================\n";
cout << "\t| January Promo Codes |\n";
cout << "\t=====================================\n\n";
cout << "1. 10% off bus ticket\t\t\t\t: \"" <<
promoCode[0] << "\"" << endl;
cout << "2. 15% off bus ticket (2pax or more)\t\t: \"" <<
promoCode[1] << "\"" << endl << endl;
cout << "TnC applied.\nNote(s):" << endl;
7
cout << "1. Only one promo code can be use at a single
time for each ticket." << endl;
cout << "2. Promo code is reusable for every purchase."
<< endl;
cout << "3. Promo code will be updated every month." <<
endl << endl;
cout << "Stay tuned for more promo codes coming next
month!!" << endl << endl;
system("PAUSE");
system("CLS");