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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
const double Milk_chocolate_price=8.50;
const double Dark_european_chocolate_price=9.75;
const double White_chocolate_price=10.50;
const double European_truffles_price=12.50;
int choice;
double Milk_chocolate, Dark_european_chocolate, White_chocolate, European_truffles;
double Milk_chocolate_total, Dark_european_chocolate_total, White_chocolate_total, European_truffles_total;
double subtotal, discount_amount, discount_total, discount_percent, total,shipping, grand_total;
char discount;
cout<<"1 - Milk Chocolate\n2 - Dark_European Chocolate\n3 - White Chocolate\n4 - European Truffles";
const int milk_chocolate=1;
const int dark_european_chocolate=2;
const int white_chocolate=3;
const int european_truffles=4;
cout<<fixed<<showpoint<<setprecision(2);
bool again=true;
char answer;
while (again)
{
cout<<"\n\nEnter your choice: ";
cin>>choice;
switch (choice)
{
case milk_chocolate:
cout<<"\nEnter the pounds of Milk Chocolate: ";
cin>>Milk_chocolate;
break;
case dark_european_chocolate:
cout<<"\nEnter the pounds of Dark European Chocolate: ";
cin>>Dark_european_chocolate;
break;
case white_chocolate:
cout<<"\nEnter the pounds of White Chocolate: ";
cin>>White_chocolate;
break;
case european_truffles:
cout<<"\nEnter the pounds of European Truffles: ";
cin>>European_truffles;
break;
default:
cout<<"\nYou did not enter 1, 2, 3, 4.\nYou entered "<<choice;
}
cout<<"\n\nDo you wanna order another chocolate(y or n)? ";
cin>>answer;
switch (answer)
{
case 'y':
again = true;
break;
case 'n':
again = false;
break;
}
}
if (Milk_chocolate>0)
{
Milk_chocolate_total=Milk_chocolate*Milk_chocolate_price;
cout<<"\n"<<Milk_chocolate<<" pounds of Milk Chocolate @ $8.50\t $"<<Milk_chocolate_total;
}
if (Dark_european_chocolate>0)
{
Dark_european_chocolate_total=Dark_european_chocolate*Dark_european_chocolate_price;
cout<<"\n"<<Dark_european_chocolate<<" pounds of Dark European Chocolate @ $9.75\t $"<<Dark_european_chocolate_total;
}
if (White_chocolate>0)
{
White_chocolate_total=White_chocolate*White_chocolate_price;
cout<<"\n"<<White_chocolate<<" pounds of White Chocolate @ $10.50\t $"<<White_chocolate_total;
}
if (European_truffles>0)
{
European_truffles_total=European_truffles*European_truffles_price;
cout<<"\n"<<European_truffles<<" pounds of European Truffles @ $12.50\t $"<<European_truffles_total;
}
subtotal=Milk_chocolate_total+Dark_european_chocolate_total+White_chocolate_total+European_truffles_total;
if ((subtotal >= 20.00) && (subtotal <= 39.99))
{
discount = 'A';
}
if ((subtotal >= 40.00) && (subtotal <= 59.99))
{
discount = 'B';
}
if ((subtotal >= 60.00) && (subtotal <= 79.99))
{
discount = 'C';
}
if (subtotal >= 80.00)
{
discount = 'D';
}
switch(discount)
{
case 'A':
discount_amount = 10;
break;
case 'B':
discount_amount = 15;
break;
case 'C':
discount_amount = 20;
break;
case 'D':
discount_amount = 25;
break;
}
discount_total=0.1*subtotal;
total=subtotal - discount_total;
shipping = total * .10;
grand_total = shipping + total;
if (grand_total > 0)
{
cout << "\n\nSubtotal $" << subtotal << "\n\nLess: " << discount_amount << "% Discount $" << discount_total <<"Total $"<<total<< "\nShipping and Handling 10% $" << shipping << "\n\nGrand Total $" << grand_total;
}
else
cout << "\nYou did not order any quantity.";
return 0;
}
|