Tuesday 15 November 2011

CS201 Assignment 1 Solution Fall 2011


Program for virtual Billing System

#include<iostream.h>
#include<conio.h>

main()
{
   
int MealPrice, NoOfCustomer=1;
float SaleTax,TotalAmount,GrandTotal=0;
char Aziz;

cout<<"*** Virtual Restaurant *** ";
StartAgain:
cout<<"\n Enter the Price of the meal: ";
cin>>MealPrice;

    if(MealPrice>0 && MealPrice<=1000)
    {
        cout<<"\n Price of Meal: "<<MealPrice;
        SaleTax=MealPrice*0;
        cout<<"\n Sales Tax    : "<<SaleTax;
        cout<<"\n-----------------------------------";
        TotalAmount=MealPrice+SaleTax;
        cout<<"\n Total Amount : "<<TotalAmount;
        cout<<"\n This customer should be served with Candies ";
    }
       
    else if(MealPrice>1000 && MealPrice<=2000)
    {
        cout<<"\n Price of Meal: "<<MealPrice;
        SaleTax=MealPrice*(.01);
        cout<<"\n Sales Tax    :"<<SaleTax;
        cout<<"\n-----------------------------------";
        TotalAmount=MealPrice+SaleTax;
        cout<<"\n Total Amount : "<<TotalAmount;
        cout<<"\n This customer should be served with Sweet Bread ";
    }  
   
    else if(MealPrice>2000 && MealPrice<=3000)
    {
        cout<<"\n Price of Meal: "<<MealPrice;
        SaleTax=MealPrice*(.02);
        cout<<"\n Sales Tax    :"<<SaleTax;
        cout<<"\n-----------------------------------";
        TotalAmount=MealPrice+SaleTax;
        cout<<"\n Total Amount : "<<TotalAmount;
        cout<<"\n This customer should be served with Pudding ";
    }
   
    else if(MealPrice>3000 && MealPrice<=4000)
    {
        cout<<"\n Price of Meal: "<<MealPrice;
        SaleTax=MealPrice*(.02);
        cout<<"\n Sales Tax    :"<<SaleTax;
        cout<<"\n-----------------------------------";
        TotalAmount=MealPrice+SaleTax;
        cout<<"\n Total Amount : "<<TotalAmount;
        cout<<"\n This customer should be served with Cake ";
    }                                                                                                        
   
    else if(MealPrice>4000)
    {
        cout<<"\n Price of Meal: "<<MealPrice;
        SaleTax=MealPrice*(.02);
        cout<<"\n Sales Tax    :"<<SaleTax;
        cout<<"\n-----------------------------------";
        TotalAmount=MealPrice+SaleTax;
        cout<<"\n Total Amount : "<<TotalAmount;
        cout<<"\n This customer should be served with Trifle ";
    }
   
     GrandTotal =GrandTotal+TotalAmount;
     
    cout<<"\n\n Do You Want to process another customer: ?";
    cout<<"\n\n Enter'Y' for Yes or 'N' for exit>:";
    cin>>Aziz;
       
     switch (Aziz)
      {
      case'Y':
      case'y':
      NoOfCustomer++;
     
      goto StartAgain;
      break;
     
      case'N':
      case'n':
      cout<<"\n\nGrand Totals: ";
      cout<<"\nTotal Customers: "<<NoOfCustomer;
      cout<<"\nTotal Amount for all Bills: "<<GrandTotal;    
      break;
      }  
     
       
                                                           
getch();  
}

No comments:

Post a Comment