1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#include <iomanip>
#include <iostream>
using namespace std;
//Bunch of global identifiers
double calc_discount(int quantity, double cost_each, double discount, int more_than);
int breakfast, lunch, dinner;
const double break_costeach=5.50, break_disc=.10, lunch_costeach=9.50, lunch_disc=.15, dinner_costeach=16.50, dinner_disc=.12;
double break_cost, lunch_cost=lunch*lunch_costeach, dinner_cost=dinner*dinner_costeach, break_costAD=break_cost*break_disc, lunch_costAD=lunch_cost*lunch_disc, dinner_costAD=dinner_cost*dinner_disc, break_discount, lunch_discount, dinner_discount;
const int break_mt=10, lunch_mt=15, dinner_mt=8;
int main()
{
break_cost=(breakfast*break_costeach);
cout<<setiosflags(ios::fixed|ios::showpoint)
<<setprecision(2);
cout<<"Enter the number of breakfasts ordered."<<endl;
cin>>breakfast;
break_discount=calc_discount(breakfast, break_costeach, break_disc, break_mt);
cout<<"Enter the number of lunches ordered."<<endl;
cin>>lunch;
lunch_discount=calc_discount(lunch, lunch_costeach, lunch_disc, lunch_mt);
cout<<"Enter the number of dinners ordered."<<endl;
cin>>dinner;
dinner_discount=calc_discount(dinner, dinner_costeach, dinner_disc, dinner_mt);
//This is for the output
cout<<" My Favorite Catering Service "<<endl<<"*******************************************************************"<<endl;
cout<<"Meal Quantity Cost Discount Cost After Discount"<<endl;
cout<<break_cost<<endl;
return 0;
}
//This is the function definition
double calc_discount(int quantity, double cost_each, double discount, int more_than)
{
double disc;
if(quantity>more_than)
quantity*cost_each*discount;
else
quantity*cost_each;
return disc;
|