Вы находитесь на странице: 1из 3

Q.

Make a KFC program that calculate the bill of five customers


and print the bill of top three customers.

#include <stdlib.h>
#include <iostream.h>

class KFC{
public:

KFC(){}
KFC(int pQty, int zQty, int fQty)
{
pepsiQty=pQty;
zingerQty=zQty;
friesQty=fQty;
}

void setPepsiQty(int pQty){pepsiQty=pQty;}


void setZingerQty(int zQty){zingerQty=zQty;}
void setFriesQty(int fQty){friesQty=fQty;}

int getPepsiQty(){return pepsiQty;}


int getZingerQty(){return zingerQty;}
int getFriesQty(){return friesQty;}

int pepsiBill()
{
return pepsiQty*15;
}

int zingerBill()
{
return zingerQty*20;
}

int friesBill()
{
return friesQty*30;
}

void billWithGrandTotal()
{
cout<<"\n\n\nItem\tQty\tPrice\n";
cout<<"\nPepsi\t "<<pepsiQty<<"\t "<<pepsiQty*15;
cout<<"\nZinger\t "<<zingerQty<<"\t "<<zingerQty*20;
cout<<"\nFries\t "<<friesQty<<"\t "<<friesQty*30;
cout<<"\n=====================";
cout<<"\nGrand Total = "<<pepsiBill()+zingerBill()
+friesBill();
cout<<"\n=====================\n";

int getGrandTotal(){return pepsiBill()+zingerBill()+friesBill();}

private:

int pepsiQty;
int zingerQty;
int friesQty;
};

void main()
{
KFC kfc[5];
int pQ,zQ,fQ;
for(int i=0;i<5;i++)
{
system("cls");
cout<<"\nEnter the Qty of Pepsi for Customer "<<i+1<<": ";
cin>>pQ;
kfc[i].setPepsiQty(pQ);
cout<<"\nEnter the Qty of Zinger for Customer "<<i+1<<": ";
cin>>zQ;
kfc[i].setZingerQty(zQ);
cout<<"\nEnter the Qty of Fries for Customer "<<i+1<<": ";
cin>>fQ;
kfc[i].setFriesQty(fQ);
}

system("cls");
for(int m=0;m<5;m++)
{
cout<<"\n\nBill of Person "<<m+1<<" is\n";
kfc[m].billWithGrandTotal();
}

for(int j=0;j<5-1;j++)
for(int k=0;k<5-1;k++){
if(kfc[k].getGrandTotal()<kfc[k+1].getGrandTotal())
{
KFC temp;
temp=kfc[k];
kfc[k]=kfc[k+1];
kfc[k+1]=temp;
}
}

cout<<"\n\nTop 3 Customers are \n\n";


for(int l=0;l<3;l++)
cout<<"Total Bill
"<<kfc[l].getGrandTotal()<<endl;

cout<<endl<<endl;

Click the link below to see more examples

URL: http://ravianeducation.blogspot.com
E-Mail: mail2ravian@gmail.com
Farhan: 03008855006

Вам также может понравиться