### Program not working

I'm trying to make a program that records orders taken then displays how many of which order was taken and the total for the orders. The program has to include a for loop. Any suggestions?

A restaurant has 3 lunch combos for customers to choose:
Combo A: Fried chicken with cold slaw [price: 6.00]
Combo B: Roast beef with mashed potato [price: 6.25]
Combo C: Fish and chips [price: 5.75]

Write a program to calculate how much a group of customers should pay. The program first asks how many customers there are in the group. Then it asks the combo ordered by each customer. If case a customer does not want to order anything, the cashier will enter X, which means order nothing, into the program. When every customer in the group has placed his/her order, the program will display the number of each combo ordered and the total amount of this groupâ€™s bill.
TEST CASE

INPUT EXPECTED OUTPUT
Number of customer in the group: 5
Combos ordered:
C B C X A Number of combo A ordered: 1
Number of combo B ordered: 1
Number of combo C ordered: 2
Total amount due: 23.75

My code:
// Lab0903.cpp -
// Created by Taft Sanders 10/12/12

#include <iostream>

using namespace std;

int main( )
{
int customer=0;

cout<<"Number of customers in the group: ";
cin>>customer;

for (int order; order<=customer; order++)
{
char combo=' ';
int a=0;
int b=0;
int c=0;

cout<< "What combo would you like: ";
cin>> combo;

if (combo=='A' || combo=='a')
{
a++;
}
else if (combo=='B' || combo=='b')
{
b++;
}
else if (combo=='C' || combo=='c')
{
c++;
}
else if (combo=='X' || combo=='x')
{
cout<< "Customer ordered nothing";
}
}
int a;
int b;
int c;
cout<<"Number of combo A ordered: "<< a << endl;
cout<<"Number of combo B ordered: "<< b << endl;
cout<<"Number of combo C ordered: "<< c << endl;

double comboA=6.00;
double comboB=6.25;
double comboC=5.75;
double total=0;

total=(comboA*a)+(comboB*b)+(comboC*c);

cout<<"Total amount due: "<< total<<endl;

system("pause");
return 0;
}
Please use code tags (the <> button), and perhaps some indentation too. It looks like you define a, b, and c in two places. Put the first declaration at the beginning of main(), and then remove the second.
I removed the 2nd declaration of the variables and moved them to the top of main. I still get basically the same output, just different numbers.

 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162`` ``````// Lab0903.cpp - // Created by Taft Sanders 10/12/12 #include using namespace std; int main( ) { int customer=0; int a; int b; int c; cout<<"Number of customers in the group: "; cin>>customer; for (int order; order<=customer; order++) { char combo=' '; int a=0; int b=0; int c=0; cout<< "What combo would you like: "; cin>> combo; if (combo=='A' || combo=='a') { a++; } else if (combo=='B' || combo=='b') { b++; } else if (combo=='C' || combo=='c') { c++; } else if (combo=='X' || combo=='x') { cout<< "Customer ordered nothing"; } } cout<<"Number of combo A ordered: "<< a << endl; cout<<"Number of combo B ordered: "<< b << endl; cout<<"Number of combo C ordered: "<< c << endl; double comboA=6.00; double comboB=6.25; double comboC=5.75; double total=0; total=(comboA*a)+(comboB*b)+(comboC*c); cout<<"Total amount due: "<< total<

Is there a way to post a screenshot of my results so that you may see what I get?
Figured out how post that screenshot. Here is what I'm getting.

 ``` Number of customers in the group: 5 Number of combo A ordered: 2686792 Number of combo B ordered: 2 Number of combo C ordered: 48 Total amount due: 1.6121e+007 Press any key to continue . . . ```
Well I'm still shooting in the dark but I think I might be getting somewhere. I took the 2nd declaration of the variables a,b,c out of the for loop. Now my program is completely skipping my for loop and going straight to the end. How do I get my for loop to compile with the program?

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960`` ``````// Lab0903.cpp - Display the number of combos order by type and total amount due // based on the number of guests enetered. // Created by Taft Sanders 10/12/12 #include using namespace std; int main( ) { int customer=0; int a=0; int b=0; int c=0; cout<<"Number of customers in the group: "; cin>>customer; for (int order; order<=customer; order++) { char combo=' '; cout<< "What combo would you like: "; cin>> combo; if (combo=='A' || combo=='a') { a++; } else if (combo=='B' || combo=='b') { b++; } else if (combo=='C' || combo=='c') { c++; } else if (combo=='X' || combo=='x') { cout<< "Customer ordered nothing"; } } cout<<"Number of combo A ordered: "<< a << endl; cout<<"Number of combo B ordered: "<< b << endl; cout<<"Number of combo C ordered: "<< c << endl; double comboA=6.00; double comboB=6.25; double comboC=5.75; double total=0; total=(comboA*a)+(comboB*b)+(comboC*c); cout<<"Total amount due: "<< total<

 ``` Number of customers in the group: 100 Number of combo A ordered: 0 Number of combo B ordered: 0 Number of combo C ordered: 0 Total amount due: 0 Press any key to continue . . . ```
Did you ever figure out what was wrong because, I would like to know too.. Thanks
Topic archived. No new replies allowed.