3. Implementation / Coding
#include<iostream>
#include<string>
using namespace std;
int main()
{
char code;
string name;
int noAdult, noChildren;
float priceAdult, priceChildren;
//adult and children are refer to the price per head.
//priceAdult and priceChild refer to the total of price every
//category after times with the quantity person.
float priceBeforeGST, GST, netPrice;
bool validCode;
cout<<endl;
cout<< "Package Code Package Types "<<endl;
cout<< "------------------------------------------------"<<endl;
cout<< " A : Umrah During Non-Peak Seasons "<<endl;
cout<< " B : Umrah During Ramadhan "<<endl;
cout<< " C : Umrah During School Holiday "<<endl;
cout<<endl<<endl;
cout<< "Package Code Adult Price Children Price "<<endl;
cout<< "------------------------------------------------ "<<endl;
cout<< " A RM6500.00 RM5000.00 "<<endl;
cout<< " B RM8500.00 RM6500.00 "<<endl;
cout<< " C RM7500.00 RM6000.00 "<<endl;
cout<<endl<<endl;
cout<< "Enter your name for booking the package "<<endl;
cin>>name;
cout<<endl;
cout<< "Enter the package code : ";
cin>>code;
cout<<endl;
if (code == 'A' || code == 'B' || code == 'C')
validCode = true;
else
validCode = false;
if (validCode == true)
{
cout<< "Enter the number of adults : ";
cin>>noAdult;
cout<<endl;
cout<< "Enter the number of children : ";
cin>>noChildren;
cout<<endl;
if ( code == 'A')
{
priceAdult = noAdult * 6500;
priceChildren = noChildren * 5000;
}
else if ( code == 'B')
{
priceAdult = noAdult * 8500;
priceChildren = noChildren * 6500;
}
else if ( code == 'C')
{
priceAdult = noAdult * 7500;
priceChildren = noChildren * 6000;
}
priceBeforeGST = priceAdult + priceChildren;
GST = priceBeforeGST * 0.06;
netPrice = priceBeforeGST + GST;
cout<<endl<<endl;
cout<< "Booking Details "<<endl;
cout<< "-------------------------------"<<endl;
cout<< "Booking Name : " << name << endl;
cout<< "Package Types : " << code << endl;
cout<< "Number of Adults : RM " << noAdult << endl;
cout<< "Number of Children : RM " << noChildren << endl;
cout<< "Price before GST : RM " << priceBeforeGST << endl;
cout<< "Tax (GST) : RM " << GST << endl;
cout<< "Net / Total Price : RM " << netPrice <<endl;
}
else
cout<< "Invalid package code.";
return 0;
}