The total bill doesn't add up correctly, don't get where I went wrong? Total bill is way off.
#include <iostream>
#include<cmath>
#include <iomanip>
#include <string>
using namespace std;
const float Small = 1.20;
const float Medium = 1.50;
const float Large = 1.70;
const float less_inches = 3.75;
const float more_inches = 4.00;
int main()
{
int No_Sand, Sand_size;
float DrinkCost = 0.0, SandCost = 0.0, total = 0.0;
float No_Drinks;
char Drink_size;
cout << fixed << showpoint << setprecision(2);
//Display Menu
cout << "------------Menu-------------" << endl;
cout << "Drinks " << endl;
cout << setfill('.');
cout << left << setw(15) << " Small" << right << setw(6) << Small << endl;
cout << left << setw(15) << " Medium" << right << setw(6) << Medium << endl;
cout << left << setw(15) << " Large" << right << setw(6) << Large << endl;
cout << "Sandwiches " << endl;
cout << left << setw(15) << " 10 inches" << right << setw(6) << less_inches << endl;
cout << left << setw(15) << " 12 inches" << right << setw(6) << more_inches << endl;
//Ask for how many drinks or sandwiches and the size of drink or sandwich
cout << "\t How many drinks: ";
cin >> No_Drinks;
cout << "\t What size(S=Small, M=Medium, L=Large)? ";
cin >> Drink_size;
cout << "\t How many sandwiches? ";
cin >> No_Sand;
cout << "\t What size(12/10 inches)? ";
cin >> Sand_size;
//Calculate Drink Cost
switch (Drink_size)
{
case 'S': case 's': DrinkCost = No_Drinks * 1.20; break;
case 'M': case 'm': DrinkCost = No_Drinks * 1.50; break;
case 'L': case 'l': DrinkCost = No_Drinks * 1.70; break;
}
//Calculate Sandwich cost
switch(Sand_size)
{
case 10: SandCost = No_Sand * 3.75; break;
case 12: SandCost = No_Sand * 4.00; break;
}
//Calculate total
total = Drink_size + Sand_size;
cout << "\t Total bill = " << total << endl;
//end program
system("pause");
return 0;
}
Output:
------------Menu-------------
Drinks
Small.........1.20
Medium........1.50
Large.........1.70
Sandwiches
10 inches.....3.75
12 inches.....4.00
How many drinks: 3
What size(S=Small, M=Medium, L=Large)? M
How many sandwiches? 3
What size(12/10 inches)? 10
Total bill = 87.00
Press any key to continue . . .