You are on page 1of 2

MUHAMAD SYARIFUDIN BIN ABDUL LATIF

2018815674
PEC221 3O

#include <iostream>
using namespace std;

char getInput();
float calcPayment(char code, char cat, int num);
int num;
char code, cat;
float price, tprice, disc;

int main()
{

char ans='y';
while (ans=='Y' || ans=='y')

{
getInput();
calcPayment(code, cat, num);
if ((code=='d'||code=='D')&& (cat=='l'||cat=='L'))
{
disc=price*0.15;
tprice=price-disc;
}
else if ((code=='d'||code=='D')&& (cat=='i'||cat=='I'))
{
disc=0;
tprice=price-disc;
}
else if ((code=='e'||code=='E')&& (cat=='l'||cat=='L'))
{
disc=price*0.15;
tprice=price-disc;
}
else
{
disc=0;
tprice=price-disc;
}
cout<<endl<<endl;
cout<<"Day Code :"<<code<<endl;
cout<<"Participant category :"<<cat<<endl;
cout<<"Number Of Partcipant :"<<num<<endl;
cout<<"Total Price :RM "<<price<<endl;
cout<<"Discount :RM "<<disc<<endl;
cout<<"Nett Price :RM "<<tprice<<endl<<endl;
cout<<"Do you want to repeat? <Y=yes , N=no> : ";
cin>>ans;
cout<<endl;
}
}

char getInput()
{

cout<<"Enter Day Code <Weekdays=D> <Weekend:E> : ";


cin>>code;
cout<<"Enter Category <Local=L> <International=I>: ";
cin>>cat;
cout<<"Number of Participant : ";
cin>>num;

return code, cat, num;


}

float calcPayment(char code, char cat, int num)


{

if ((code=='d'||code=='D')&& (cat=='l'||cat=='L'))
price=250*num;
else if ((code=='d'||code=='D')&& (cat=='i'||cat=='I'))
price=275*num;
else if ((code=='e'||code=='E')&& (cat=='l'||cat=='L'))
price=300*num;
else
price=325*num;

return price;
}