I'm trying to write a c++ program that first asks how may people are in a party, then it takes that number to calculate how many times to ask what the next person wants to order. This is what I have so far. I can get the program to recognize how many people I have entered in for the amount of people in a party. What I'm having a problem with is totaling the amount and then displaying the total amount due. The available menu items are a, b, c, d, and x. Each one has a value amount except for x. So if x is entered, then there is no amount to add to the total.
With what I have right now, the program will ask and hold the amount of people in the party. So the program will ask for an order the correct amount of time, but it isn't totaling my cost. So somewhere I'm missing a holder for the total and I'm just not sure on that part. Any help is greatly appreciated.
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main( )
{
char itemOrdered = ' ';
double customers = 0.0;
double total = 0.0;
int numCustomers = 0;
cout << "Enter number of customers in party: ";
cin >> numCustomers;
cout << "This program calculates total for " << numCustomers << " customers." << endl;
for (int counter = 0; counter < numCustomers; counter = counter + 1)
{
cout << "Our lunch menu today: " << endl;
cout << " Combo A: Fried chicken with slaw $4.25" << endl;
cout << " Combo B: Roast beef and mashed potato $5.75" << endl;
cout << " Combo C: Fish and chips $5.25" << endl;
cout << " Combo D: Soup and salad $3.75" << endl;
cout << "Enter combo code[A/B/C/D] or X for no order: ";
cin >> itemOrdered;
itemOrdered = toupper(itemOrdered);
for (char itemOrdered = 0; itemOrdered < numCustomers;)
{
switch(itemOrdered)
{
case 'A': total = total + 4.25;
break;
case 'B': total = total + 5.75;
break;
case 'C': total = total + 5.25;
break;
case 'D': total = total + 3.25;
break;
case 'x': total = total + 0.00;
}
cout << "Enter next item ordered [A/B/C/D/X] : ";
cin >> itemOrdered;
itemOrdered = toupper(itemOrdered);
}
}
cout << "Please pay this amount: " << total << endl;
system("pause");
return 0;
}