Hi! I'm lost. I'm trieng to write the program. It just won't work. I posted the code below.
Code:
#include <iostream>
using namespace std;
int main ()
{
    const int NrOfShops = 3;
    float price;
    char sweets, userAnswer;
    bool answer;
    
// declare and initialize totals
float totChoc = 0,0, totChips = 0.0, totIce = 0.0, totOther = 0.0 totSweets = 0.0;
// loop over the number of shops
for (int i = 1; i <= 3; i++)
{
    answer = true;
    cout << "Enter the sweets boaught at Shop nr: " << i << endl;
    
// sentinel while loop prompting for kind of sweets bought
while (i <= 3 && sweets == 0)
        {
         cout << "c=chocolate, h = chips, i = ice-cream, o = other and 0 to end: and price: " << endl;
         cin >> sweets, price;
        }
// enter the kind of sweets bought (c=chocolate,
// ch = chips, i = ice-cream, o = other) as well as price
// Update the total cost per kind of sweet
                switch (userAnswer)
                {
                 case 'c':
                      (userAnswer++) * price;
                      
                      break;  
                 case 'h':
                      (userAnswer++) * price;
                      break;
                 case 'i':
                      (userAnswer++) * price;
                      break;
                 case 'o':
                      (userAnswer++) * price;
                      break;
                }
}
// display total spent for each kind of sweet
// update total spent on all sweets so far
// reset totals of sweets
// display total spent on sweets at all shops
system ("pause");
return 0;
}
I hope the comments will help you to understand what I'm attempting to do. I't is just not working and I don't know how to fix it. Any assistance will be welcome!

Thank you
Mollera

Last edited by shabbir; 20Apr2010 at 06:47.. Reason: Code blocks