Pages

hye all



Sunday 25 March 2012

coding rasyid

haii.....
hari nih aku nak syerr coding yang member class aku buat.....
wah2....very amazing.....
x dapat aku nafikan dy memng hebat.....
sagt hebat,....
nama dia..: rasyid shauqi 
umur :         19
class:         KCS1102C
status:        x tahu..




#include <iostream>
#include <conio>
#include <fstream>
#include <time>
struct food{
char combo,add,addans,member,cpayment,ccombo;
int cadd,dri,chee,sal,yog,pay,typemember,service;
int Acomprice,Bcomprice,Ccomprice,Dcomprice;
float totaladd,dismember,totalall,payment,lastpaid,totalcom;
};
void list();
void choose(food &f);
void calculate(food &f);
void Pay(food &f);
void bill(food &f);
void resit(food &f);
void wait(float second);
main()
{
food f;
char loop;
do{
cout<<endl;
cout<<"\t\t:::::::::WELCOME TO DRIVETHROUGH COMBO KING:::::::\n";
cout<<"\t\t::::::IT'S SUPER DUPER TASTY YET HEALTHY FOOD:::::\n";
cout<<"\t\t:::PLEASE MAKE A WISE CHOICE BEFORE YOU PROCEED:::\n";
cout<<"\n::HOME::\n";
cout<<"\n(1) List of food combo menu";
cout<<"\n(2) Key in your choice";
cout<<"\n(3) Make a payment";
cout<<"\n(4) Your bill";
cout<<"\n(5) Your receipt";
cout<<"\n\n(Advise) - Please choose the menu in the order.";
cout<<"\nEnter your choice of menu : ";
cin>>f.service;
if(f.service==1){
clrscr();
list();}
else if(f.service==2){
clrscr();
choose(f);
calculate(f);}
else if(f.service==3){
clrscr();
Pay(f);}
else if(f.service==4){
clrscr();
bill(f);}
else if(f.service==5){
clrscr();
for(int i=0;i<10;i++)
{
clrscr();
cout<<"Please wait for seconds. Your receipt is being printed.";
cout<<endl<<i;
wait(1);
}
resit(f);
cout<<"\nYour receipt has been printed. Here you go!";}
else
cout<<"\nError input. Please key in your choice again, later.";
cout<<"\n\nReturn home or exit? (y-return home/n-exit): ";
cin>>loop;
clrscr();
}while(loop=='y'||loop=='Y');
cout<<"\nHave a nice day!";
getch();
}


void list(){
cout<<"\n\t::: Combo A (RM25): \tCombo B (RM40): :::";
cout<<"\n\n\t::: Chicken bucket (10/small)\tChicken bucket (18/medium) :::";
cout<<"\n\t::: French Fries \tFrench Fries :::";
cout<<"\n\t::: Coleslaw \tColeslaw :::";
cout<<"\n\t::: Drink \tIce cream Cup :::";
cout<<"\n\t::: \tDrink :::";
cout<<"\n\n\t::: Combo C (RM55): \tCombo D (RM75): :::";
cout<<"\n\n\t::: Chicken bucket (25/large)\tChicken bucket (40/xtra large) :::";
cout<<"\n\t::: French Fries \tFrench Fries :::";
cout<<"\n\t::: Coleslaw \tColeslaw :::";
cout<<"\n\t::: Hot Chicken Soup \tHot Chicken Soup :::";
cout<<"\n\t::: Ice cream Cup \tIce cream Cup :::";
cout<<"\n\t::: Drink \tDrink :::";
cout<<"\n\t::: \tSpaghetti Bolognese :::";
}


void choose(food &f){
cout<<"\n\nPlease choose wisely. Your kindness is splendid to us";
f.Acomprice=0,f.Bcomprice=0,f.Ccomprice=0,f.Dcomprice=0;
do{
cout<<"\nWhich Combo do you prefer? : ";
cin>>f.combo;
if(f.combo=='a'||f.combo=='A'){
cout<<"How many : ";
cin>>f.Acomprice;}
else if(f.combo=='b'||f.combo=='B'){
cout<<"How many : ";
cin>>f.Bcomprice;}
else if(f.combo=='c'||f.combo=='C'){
cout<<"How many : ";
cin>>f.Ccomprice;}
else if(f.combo=='d'||f.combo=='D'){
cout<<"How many : ";
cin>>f.Dcomprice;}
cout<<"\nDo you want another combo? (y/n): ";
cin>>f.ccombo;
}while(f.ccombo=='y'||f.ccombo=='Y');


cout<<"Do you prefer to put add on? (y/n): ";
cin>>f.add;


f.dri=0,f.chee=0,f.sal=0,f.yog=0;
if(f.add=='y'||f.add=='Y'){
cout<<"\n\t\tThis is a list of add on food: ";
cout<<"\n\t\t1 - Non-carbonate drink\t2 - Cheesy Weesy Wedges";
cout<<"\n\t\t3 - Salad\t4 - Yogurt";
do{
cout<<"\nWhich add on do you like : ";
cin>>f.cadd;
if(f.cadd==1){
cout<<"How many : ";
cin>>f.dri;}
else if(f.cadd==2){
cout<<"How many : ";
cin>>f.chee;}
else if(f.cadd==3){
cout<<"How many : ";
cin>>f.sal;}
else if(f.cadd==4){
cout<<"How many : ";
cin>>f.yog;}


cout<<"\nDo you want another add on? (y/n)";
cin>>f.addans;
}while(f.addans=='y'||f.addans=='Y');}
cout<<"Do you have membership card? (y/n) : ";
cin>>f.member;
if(f.member=='y'||f.member=='Y'){
cout<<"Which type member are you? ";
cout<<"\n(1-gold /2-silver /3-bronze) : ";
cin>>f.typemember;}
cout<<"\nThank you. Now, please take your time before";
cout<<"\nwe prepare the order. Please drive to the next door.";
}


void calculate(food &f){
f.totalcom=0;
f.totalcom=(25*f.Acomprice)+(40*f.Bcomprice)
+(55*f.Ccomprice)+(75*f.Dcomprice);


f.totaladd=0;
f.totaladd=(2*f.dri)+(1.5*f.chee)+(3*f.sal)+(1.8*f.yog);


{
if(f.member=='y'||f.member=='Y'){
if(f.typemember==1){
f.dismember=0.85;}
else if(f.typemember==2){
f.dismember=0.9;}
else if(f.typemember==3){
f.dismember=0.95;}
}
else
f.dismember=1;}


f.totalall=(f.totalcom+f.totaladd)*f.dismember;}


void Pay(food &f){
cout<<"\nHere is your order!";
cout<<"\n\nThe total price is RM"<<f.totalall;
cout<<"\nHow do you prefer to pay? (1-card / 2-cash) : ";
cin>>f.pay;


do{
if(f.pay==2)
{
cout<<"\nPlease input your payment cash : RM";
cin>>f.payment;
f.lastpaid=0;
if(f.payment>f.totalall)
{
f.lastpaid=f.payment-f.totalall;
cout<<"\nHere is your balance : RM"<<f.lastpaid;
}
else if(f.payment==f.totalall)
{
f.lastpaid=f.payment-f.totalall;
cout<<"\nThank you for paying exactly same as the bill";
}
else if(f.payment<f.totalall)
{
f.lastpaid=f.totalall-f.payment;
cout<<"\nYour payment is not sufficient. \nYou need to pay RM"<<f.lastpaid<<
" more for the payment.";
}
cout<<"\nDo you input the right payment? (y/n) : ";
cin>>f.cpayment;
}
else if(f.pay==1)
cout<<"\nThe payment will be added into your bank account";
}while(f.cpayment=='n'||f.cpayment=='N');}


void bill(food &f){
cout<<"\nThis is your bill";
cout<<"\n\n";
cout<<"\nTotal Combo price\t: RM"<<f.totalcom;
cout<<"\nTotal add on price\t: RM"<<f.totaladd;
cout<<"\nTotal price\t\t: RM"<<(f.totalcom+f.totaladd);
if(f.member=='y'||f.member=='Y'){
cout<<"\nMembership discount\t: "<<((1-f.dismember)*100)<<"%";
cout<<"\nTotal price after disc.\t: RM"<<f.totalall;}
if(f.pay==2){
cout<<"\nPayment\t\t\t: RM"<<f.payment;
cout<<"\nBalance\t\t\t: RM"<<f.lastpaid;}
}


void resit(food &f){
fstream resits;
resits.open("resit.txt", ios::out);
resits<<"\n:::WELCOME TO DRIVETHROUGH COMBO KING:::\n\n\n";
resits<<"\nTotal combo price\t: RM"<<f.totalcom;
resits<<"\nTotal add on price\t: RM"<<f.totaladd;
resits<<"\nTotal price\t\t: RM"<<(f.totalcom+f.totaladd);
if(f.member=='y'||f.member=='Y'){
resits<<"\nMembership discount\t: "<<((1-f.dismember)*100)<<"%";
resits<<"\nTotal price after disc.\t: RM"<<f.totalall;}
if(f.pay==2){
resits<<"\nPayment\t\t\t: RM"<<f.payment;
resits<<"\nBalance\t\t\t: RM"<<f.lastpaid;}
resits<<"\n\n\n:::THANK YOU FOR COMING!:::";
resits<<"\n:::PLEASE COME AGAIN!::::::";
resits<<"\n\n\n\nNUM CONTACT: 1300 88 2525\t\tEMAIL: comboking@gmail.com";
resits<<"\nFACEBOOK: www.facebook.com/comboking";
resits.close();
}
void wait(float second)
{
clock_t wait;
wait=clock()+second*CLOCKS_PER_SEC;
while(clock()<wait){}
}






p/s: try lah run....guna BOOLEN c++

No comments:

Post a Comment