#include<iostream.h>
// program to calculate meal prices
// use of if else statements
// use of switch statement
// use of break function.
main()
{
int MealPrice =1; // defining mealPrice
int noOfcustomer=1;// defining number of customers
float SalesTax,TotalAmount,GrandTotal=0;
char choice;
cout <<"\n\t***CS201- Intro to Programming***:";
cout<<"\n\t Brogram by Muhammad Farrukh";
cout<<"\n\t http://cpp-hotseat.blogspot.com";
cout<<"\n\n_____________________________________";
startagain:
cout <<"\n enter the price of meal:";
cin>>MealPrice; // getting meal price from the user
// if meal price between 0 - 1000
if(MealPrice>0 && MealPrice<=1000)
{
cout <<"\n Price of Meal:"<<MealPrice;
SalesTax= MealPrice*0;
cout <<"\n SalesTax :"<<SalesTax;
cout <<"\n--------------------------:";
TotalAmount=MealPrice+SalesTax;
cout <<"\nTotalAmount :"<<TotalAmount;
cout <<"\nThis customer should be served with Candies:";
}
// if meal price is between 1000 - 2000
else if(MealPrice>=1000 && MealPrice<2000)
{
cout <<"\nPrice Of Meal:"<<MealPrice;
SalesTax=MealPrice*1/100;
cout <<"\nSalesTax :"<<SalesTax;
cout <<"\n--------------------------:";
TotalAmount=MealPrice+SalesTax;
cout <<"\nTotalAmount:"<<TotalAmount;
cout <<"\nThis customer should be serve with Sweet Bread:";
}
// if meal price is between 2000 - 3000
else if(MealPrice>=2000 && MealPrice<3000)
{
cout <<"\n Price of Meal:"<<MealPrice;
SalesTax=MealPrice*2/100;
cout <<"\n SalesTax:"<<SalesTax;
cout <<"\n--------------------------:";
TotalAmount=MealPrice+SalesTax;
cout <<"\n TotalAmount: "<<TotalAmount;
cout <<"\n This customer should be serve with pudding:";
}
// if meal price >= 3000 or meal price < 4000
else if(MealPrice>=3000 && MealPrice<4000)
{
cout <<"\n Price of Meal:"<<MealPrice;
SalesTax=MealPrice*2/100;
cout <<"\n SalesTax :"<<SalesTax;
cout <<"\n---------------------------:";
// calculating the total amoung
TotalAmount=MealPrice+SalesTax;
cout <<"\n =TotalAmount:"<<TotalAmount;
cout <<"\n This customer should be serve with cake:";
}
else if(MealPrice>4000)
{
cout <<"\n Price of Meal:"<<MealPrice;
//calculating sales Tax
SalesTax=MealPrice*2/100;
cout <<"\n SalesTax :"<<SalesTax;
cout <<"\n---------------------------:";
//calculating the total amount
TotalAmount=MealPrice+SalesTax;
cout <<"\nTotalAmount :"<<TotalAmount;
cout <<"\nThis customer should be serve with trifle:";
}
//calculating the grand total
GrandTotal=GrandTotal+TotalAmount;
cout <<"\n\n Do you want to process another customer:?";
cout <<"\n\n Enter 'Y' for Yes or 'N' to exit>:";
cin>>choice;
// Switch Statement.....
switch(choice)
{
case'Y':
case'y':
noOfcustomer=1;
goto startagain;
break;
case'N':
case'n':
cout <<"\n\nGrandtotal:";
cout <<"\nTotalcustomer:"<<noOfcustomer;
cout <<"\nTotalAmount for all bills:"<<GrandTotal;
break;
}
}
MyBlog:2(CPP-hotseat) MyBlog:3(Desibeats)
By Muhammad Farrukh
No comments:
Post a Comment
“You can't change the past, but you can ruin the present by worrying about the future”