Wednesday, 15 June 2016

A Program on Cafe billing.

C++ Code





#include<fstream>
#include<iostream>
using namespace std;
int starter ();
int continental ();
int chinese ();
int coffee ();
int desert ();
  
  


  int main ()

{
//***Variabel Declaration***//
int optp=1, item, bill=0,total=0;
 string  username ;
 string password ;

cout<<"Enter your admin details \n\nUser Name : ";
cin>>username;
cout<<"Password : ";
cin>>password;

if(username == "admin" ||  password=="*******")
{

while (optp!=6)
{
bill=bill+total;


cout<<"\n\n\nWelcome to Friends Cafe\n\n\n\t\t*********************MENU**********************\n\nCategories"; 
cout<<"\nPress:\n 1.     Starters\n 2.   Continental\n 3. Chinese\n 4. Coffee & Tea\n 5. Deserts\n 6. Exit \n\n" ;
cin>>optp;

if (optp==1  )
total=starter ();




if (optp==2)
  total=continental ();

if(optp==3)
total=chinese ();


if(optp==4)
total=coffee ();


if (optp==5)
total=desert ();

    
if (optp==6)
break;
else 
cout<<"Wrong Selection, Please select again\n";

}


//************asking details of customer*****************//
//if (bill!=0)
{



char name[100]={0};
string name1;
cout<<"\n\nKindly enter customer's Name & ID = ";
cin>>name1; 

//converting string into char array


for (int i=0 ; i<name1.length()  ; i++ )
{

name[i]=name1[i];

}
//********************************



//********Customer Matching from previous database**********//

int check=0,i=0;
char arr[100];
char  counter;

ifstream b;
b.open("imp_file",ios::in );

while(!b.eof())
{

b>>counter;

arr[i]=counter;

if (counter=='.')
{

for(int k=0; k<name1.length(); k++)
{

        if (arr[k]==name[k])

check=1;


else
{
check=0;
break;
}
}
i=-1;
}

if (check==1)
{
cout<<"\n-> Customer matches our database";
break;
}

i++;
}
b.close();
//******************************************


if (check==0)
{

//****Putting Customer data into file******
ofstream a;
a.open("imp_file",ios::app );
a<<name1<<".\n";
a.close();
//*****************************************
}


//*****Billing***********
float net =bill+ bill*0.16 ;
float discount= net - net*0.10;

if (check==1)
{
cout<<"\n\n\n\n\t\t\t-------------------------------\n\t\t\tYour bill is   "<<bill<<"\n\t\t\t16% GST included "<<bill*0.16;
cout<<"\n\t\t\t_______________________________\n\t\t\tTotal Bill = "<<net<<"\n\t\t\t10% Old Customer Discount "<<net*0.10<<"\n\t\t\t_______________________________";
cout<<"\n\t\t\tDiscounted bill is "<<discount<<"\n\n\t\t\t-------------------------------\n\n";
}
else
{

cout<<"\n\n\n\n\t\t\t------------------------\n\t\t\tYour bill is   "<<bill<<"\n\t\t\t16% GST included "<<bill*0.16;
cout<<"\n\t\t\t________________________\n\t\t\tTotal Bill = "<<net<<"\n\t\t\t________________________";
}

}

cout<<"\n\n\n                     \"THANKYOU FOR VISITING |FRIENDS CAFE|\"\n\n\n                       ";

}
else 
cout<<"\n incorrect password ";

return 0;
}







int starter (){

int item;
cout<<"\nPress:\n\n";
cout<<" 1.  Pineapple Juice       Rs-/120\n";
cout<<" 2.  Garlic Bread (4 pcs)  Rs-/250\n";
cout<<" 3.  Crunches              Rs-/100\n";
cout<<" 4.  Finger Fish           Rs-/150\n";
cin>>item;
if(item==1)
return 120;

if(item==2)
return 250;

if(item==3)
return 100;

if(item==4)
return 150;
        }

int continental ()
{
int item;
cout<<"\nPress:\n\n";
cout<<" 1.  Chicken Karahi          Rs-/300\n";
cout<<" 2.  Mutton Karahi           Rs-/600\n";
cout<<" 3.  Chicken Sajji           Rs-/550\n";
cout<<" 4.  Cheese Kabab            Rs-/400\n";
cin>>item;
if(item==1)
return 300;

if(item==2)
return 600;

if(item==3)
return 550;

if(item==4)
return 400;

        }


int chinese ()
{
int item;
cout<<"\nPress:\n\n";
cout<<" 1.  Chicken Manchurian           Rs-/700\n";
cout<<" 2.  Chicken Chouwmin             Rs-/550\n";
cout<<" 3.  Chicken Jalfrazi             Rs-/500\n";
cout<<" 4.  Pasta                        Rs-/350\n";
cin>>item;

if(item==1)
  return 700;

if(item==2)
return 550;

if(item==3)
return 500;

if(item==4)
return 350;


}



int coffee ()
{
int item;
cout<<"\nPress:\n\n";
cout<<" 1.  Coffee Latte               Rs-/250\n";
cout<<" 2.  Cappacinno                 Rs-/200\n";
cout<<" 3.  Espresso                   Rs-/300\n";
cout<<" 4.  Tea                        Rs-/120\n";
cin>>item;

if(item==1)
  return 250;

if(item==2)
return 200;

if(item==3)
return 300;

if(item==4)
return 120;


}
int desert ()
{
int item;
cout<<"/nPress:\n\n";
cout<<" 1.  Molten Lava    Rs-/270\n";
cout<<" 2.  Choco Pie      Rs-/130\n";
cout<<" 3.  Creamy Donut   Rs-/120\n";
cout<<" 4.  Tutti Frutti   Rs-/350\n";
cin>>item;
if(item==1)
return 270;

if(item==2)
return 130;

            if(item==3)
return 120;

if(item==4)
return 350;


}


Posted in: