Code:
#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
float CalcPriceMember1(int,float&,int&);
float CalcPriceMember2(int,float&,int&);
float CalcPriceNonMember1(int,float&,int&);
float CalcPriceNonMember2(int,float&,int&);
void EnterName();
void MemberType();
void PCType();
float TotalSales(float, float, float, float);
main()
{
//VARIABLE DECLARATION
char response;
int hours;
int count;
float member_price,member_price2,non_member_price,non_member_price2;
float jumlahbayar, jumlahjualan;
char ahli [4];
char nama [15];
char jenispc [10];
//INPUT FROM USER
cout<<"-------------------------------------------------------------"<<endl;
cout<<" |Welcome to MYCyber Cafe| "<<endl;
cout<<" "<<endl;
cout<<"_______________________________¶¶¶¶¶¶¶¶¶_____________________"<<endl;
cout<<"_____________________________¶¶__________¶¶__________________"<<endl;
cout<<"_______________¶¶¶¶¶______¶¶_______________¶¶________________"<<endl;
cout<<"______________¶_____¶____¶¶_____¶¶____¶¶_____¶¶______________"<<endl;
cout<<"______________¶_____¶___¶¶______¶¶____¶¶_______¶¶____________"<<endl;
cout<<"______________¶____¶__¶¶________¶¶____¶¶________¶¶___________"<<endl;
cout<<"_______________¶___¶___¶_________________________¶¶__________"<<endl;
cout<<"_____________¶¶¶¶¶¶¶¶¶¶¶¶________________________¶¶__________"<<endl;
cout<<"____________¶____________¶_¶¶_____________¶¶_____¶¶__________"<<endl;
cout<<"___________¶¶____________¶__¶¶____________¶¶_____¶¶__________"<<endl;
cout<<"__________¶¶´´´¶¶¶¶¶¶¶¶¶¶¶____¶¶________¶¶_______¶¶__________"<<endl;
cout<<"__________¶_______________¶_____¶¶¶¶¶¶¶_________¶¶___________"<<endl;
cout<<"__________¶¶______________¶____________________¶¶____________"<<endl;
cout<<"___________¶___¶¶¶¶¶¶¶¶¶¶¶¶___________________¶¶_____________"<<endl;
cout<<"___________¶¶___________¶__¶¶________________¶¶______________"<<endl;
cout<<"____________¶¶¶¶¶¶¶¶¶¶¶¶_____¶¶____________¶¶________________"<<endl;
cout<<"________________________________¶¶¶¶¶¶¶¶¶¶¶__________________"<<endl;
cout<<" "<<endl;
cout<<" AWESOME!!! "<<endl;
cout<<"-------------------------------------------------------------"<<endl;
cout<<"Do you want to continue? YES='Y' or NO='N' :";
cin>>response;
//REPETITION
while (response!='N')
{
cout<<"Price will be calculated based on the hour input by the user."<<endl;
cout<<" <MEMBER> <NON MEMBER> "<<endl;
cout<<"<PREMIUM>=RM6 PER HOUR WITH 30% DISCOUNT RM6 PER HOUR "<<endl;
cout<<"<REGULAR>=RM4 PER HOUR WITH 30% DISCOUNT RM4 PER HOUR "<<endl;
cout<<"-------------------------------------------------------------"<<endl;
EnterName();
MemberType();
PCType();
cout<<"Enter the required hours :";
cin>>hours;
//COMPARISON
if (strcmp(ahli,"YES")==0)
{
if (strcmp(jenispc,"PREMIUM")==0)
{
//OPERATION
CalcPriceMember1 (hours,member_price,count);
}
else if (strcmp(jenispc,"REGULAR")==0)
{
//OPERATION
CalcPriceMember2(hours,member_price2,count);
}
}
else if (strcmp(ahli,"NOT")==0)
{
if (strcmp(jenispc,"PREMIUM")==0)
{
//OPERATION
CalcPriceNonMember1 (hours,non_member_price,count);
}
else if (strcmp(jenispc,"REGULAR")==0)
{
//OPERATION
CalcPriceNonMember2 (hours,non_member_price2,count);
}
}
//DISPLAY THE RECEIPT
jumlahbayar=member_price,member_price2,non_member_price,non_member_price2;
cout<<" "<<endl;
cout<<"======================================================="<<endl;
cout<<" MYCyber Cafe Billing Receipt "<<endl;
cout<<"======================================================="<<endl;
cout<<"User :"<<(strcpy, nama)<<endl;
cout<<"Member type :"<<(strcpy,ahli)<<endl;
cout<<"PC type :"<<(strcpy,jenispc)<<endl;
cout<<"Hour(s) spent :"<<hours<<endl;
cout<<"Total pay(RM) :"<<jumlahbayar<<endl;
cout<<"==============THANK YOU PLEASE COME AGAIN=============="<<endl;
cout<<" "<<endl;
cout<<"Do you want to continue YES='Y' or NO='N' :";
cin>>response;
}
//DISPLAY THE RESULT TOTAL SALES CALCULATED PER DAY
jumlahjualan=TotalSales(member_price,member_price2,non_member_price,non_member_price2);
cout<<" "<<endl;
cout<<" "<<endl;
cout<<"======================================================="<<endl;
cout<<" MYCyber Cafe Total Sales Collected "<<endl;
cout<<"======================================================="<<endl;
cout<<"Total Sales Collected Per Day (RM) : "<<jumlahjualan<<endl;
cout<<"Number Of Customers Per Day : "<<count<<endl;
getch();
}
//FUNCTION DEFINITION
void EnterName()
{
char name[15];
cout<<"Please enter your first name :";
cin>>name;
}
void MemberType()
{
char member[4];
cout<<"Are you a member? (YES) or (NOT) :";
cin>>member;
}
void PCType()
{
char pctype[8];
cout<<"Which type of PC are you prefer (PREMIUM) or (REGULAR) :";
cin>>pctype;
}
float TotalSales(float total1,float total2, float total3, float total4)
{
float total;
total=total1+total2+total3+total4;
return total;
}
float CalcPriceMember1 (int jam,float& member_price,int& count)
{
member_price=(jam*6.00)-(0.3*jam*6.00);
count=count+1;
return member_price, count;
}
float CalcPriceMember2 (int jam,float& member_price2,int& count)
{
member_price2=(jam*4.00)-(0.3*jam*4.00);
count=count+1;
return member_price2, count;
}
float CalcPriceNonMember1 (int jam,float& non_member_price,int& count)
{
non_member_price=jam*6.00;
count=count+1;
return non_member_price, count;
}
float CalcPriceNonMember2 (int jam,float& non_member_price2,int& count)
{
non_member_price2=jam*4.00;
count=count+1;
return non_member_price2, count;
}