with what i read in your comment maybe you want this.
check it and tell me.
Code:
#include <iostream>
using namespace std;
int main (){
const int NrOfShops = 3;
float price;
char sweets;
// declare and initialize totals
float totChoc[NrOfShops] ={0}, totChips[NrOfShops] ={0}, totIce[NrOfShops] ={0}, totOther[NrOfShops] ={0}, totSweets=0;
// loop over the number of shops
for (int i = 0; i <NrOfShops; i++){
sweets='1';
//answer = true;
cout << "Enter the sweets bought at Shop nr: " << (i+1) << endl;
// sentinel while loop prompting for kind of sweets bought
// enter the kind of sweets bought (c=chocolate,
// ch = chips, i = ice-cream, o = other) as well as price
while (sweets != '0'){
cout << "c=chocolate, h = chips, i = ice-cream, o = other and 0 to end:";
cin >> sweets;
getchar();
if (sweets!='0'){
cout << "money paid: ";
cin >> price;
getchar();
switch (sweets){// Update the total cost per kind of sweet
case 'c':
totChoc[i]+=price;
totSweets+=price;
break;
case 'h':
totChips[i]+=price;
totSweets+=price;
break;
case 'i':
totSweets+=price;// update total spent on all sweets so far for all shops
totIce[i]+=price;
break;
case 'o':
totSweets+=price;
totOther[i]+=price;
break;
}//end switch
}//end if
}//end while
}//end for
for (int i=0;i<NrOfShops;i++){// display total spent for each kind of sweet per shop
cout<<"shop Nr "<<(i+1)<<":"<<endl;
cout<<"chocolate spent:"<<totChoc[i]<<endl;
cout<<"chips spent:"<<totChips[i]<<endl;
cout<<"ice-cream spent:"<<totIce[i]<<endl;
cout<<"other spent:"<<totOther[i]<<endl;
cout<<endl;
}
cout<<"totaly spent on sweets on all shops is "<<totSweets<<endl;// display total spent on sweets at all shops
for (int i=0;i<NrOfShops;i++){// reset totals of sweets
totChoc[i]=0;
totChips[i]=0;
totIce[i]=0;
totOther[i]=0;
}
totSweets=0;
getchar();
return 0;
}//end main