amipunye
unknown
c_cpp
2 years ago
3.6 kB
12
Indexable
#include <iostream>
#include <string.h>
using namespace std;
int main ()
{
double hour, price, totalfee;
char name [50], courtType [20], membership[3], applyMembership[3], choose[3];
cout<<"Hi! Welcome to Athletic Hub Sports Center. "<<endl;
cout<<"Would you like to book a court here? (Yes / No) : ";
cin>>choose;
cout<<"Enter your name: ";
cin.ignore();
cin.getline(name, 50);
cout<<"Here's the price list of court available. "<<endl;
cout<<"Court Type -----------------------------Price Per Hour"<<endl;
cout<<"Squash Court RM 15 "<<endl;
cout<<"Badminton Court RM 18 "<<endl;
cout<<"Futsal Court RM 18 "<<endl;
cout<<"Volleyball Court RM 20 "<<endl;
cout<<"Tennis Court RM 24 "<<endl;
cout<<"Basketball Court RM 30 "<<endl;
cout<<"\n\nWhat type of court do you want to book? (Enter the name of the sport only): "<<endl;
cin>>courtType;
cout<<"\nHow many hours do you want to book the court? : ";
cin>>hour;
while (strcmp (choose, "No") != 0)
{
if (strcmp (courtType, "Squash") == 0 || (courtType, "squash") == 0)
price = 15*hour;
else if (strcmp (courtType, "Badminton") == 0 || (courtType, "badminton") == 0)
price = 18*hour;
else if (strcmp (courtType, "Futsal") == 0 || (courtType, "futsal") == 0)
price = 18*hour;
else if (strcmp (courtType, "Volleyball") == 0 || (courtType, "volleyball") == 0)
price = 20*hour;
else if (strcmp (courtType, "Tennis") == 0 || (courtType, "tennis") == 0)
price = 24*hour;
else if (strcmp (courtType, "Basketball") == 0 || (courtType, "basketball") == 0)
price = 30*hour;
else
{
cout<<"Sorry, the court type you just entered is invalid. Try again. "<<endl;
continue;
}
cout<<"\n!! 10 Percent Discount for those who have a membership !!"<<endl;
cout<<"\nDo you have a membership? (Yes / No): ";
cin>>membership;
if (strcmp(membership, "Yes") == 0)
totalfee = price*0.9;
else if (strcmp(membership, "No") == 0)
{
cout<<"\nDo you want to apply for a membership for RM 10 only? \nYou can use it to get a discount the next time you want to book a court here! (Y-Yes, N-No): ";
cin>>applyMembership;
if (strcmp(applyMembership, "Yes") == 0)
totalfee = price + 10;
else if (strcmp(applyMembership, "No") == 0)
totalfee = price;
else
{
cout<<"Please enter a valid input.";
continue;
}
}
else
{
cout<<"Please enter a valid input.";
continue;
}
cout<<"\nThe total payment for the booking of "<<courtType<<" court by " <<name<< " is RM "<<totalfee<<endl;
cout<<"\nHope you have a wonderful time playing at our court!"<<endl;
cout<<"\nHope to see you again!"<<endl;
cout<<"\nDo you want to book another court? (Yes / No) : ";
cin>>choose;
if (strcmp(choose, "No") == 0)
break;
cout<<"\n\nWhat type of court do you want to book? (Enter the name of the sport only): "<<endl;
cin>>courtType;
cout<<"\nHow many hours do you want to book the court? : ";
cin>>hour;
}
return 0;
}Editor is loading...
Leave a Comment