basically with this program you enter a customer name (Exit to stop processing) for each customer input amount spent on each service, and you display the customers purchases. But if i enter the number 0 the next customer that i enter something in the field that was 0 in the prvious statement does not show in the customers purchases.
double hairStyle[10] = {0};
double hairColour[10] = {0};
double manicure[10] = {0};
double total[10] = {0};
int stylepos = 0, int colourPos = 0, int maniPos = 0, int totalPos = 0;
int indexStyle = 0, int indexColour = 0, int indexManicure = 0, int indexTotal = 0 ;
int count = 0;
int numberOfTimesEntered = 0;
string name;
cout << "Enter customer's Name: ";
cin >> name;
while(name != "Exit")
{
cout << endl << endl;
cout << fixed << showpoint;
double styleIn;
cout << "Enter the price for this customer's hair style : ";
cin >> styleIn;
while(styleIn < 20.00 || styleIn > 200.00){
if(styleIn == 0){
break;
}
cout << "Price entered is out of range, Please re-enter price" << endl;
cout << "Enter the price for this customer's hair style : ";
cin >> styleIn;
}
hairStyle[stylepos++] = styleIn;
double colourIn;
cout << "Enter the price for this customer's hair colour : ";
cin >> colourIn;
while(colourIn < 20.00 || colourIn > 200.00){
if(colourIn == 0){
break;
}
cout << "Price entered is out of range, Please re-enter price" << endl;
cout << "Enter the price for this customer's hair colour : ";
cin >> colourIn;
}
hairColour[colourPos++] = colourIn;
double maniIn;
cout << "Enter the price for this customer's manicure : ";
cin >> maniIn;
while(maniIn < 20.00 || maniIn > 200.00){
if(maniIn == 0){
break;
}
cout << "Price entered is out of range, Please re-enter price" << endl;
cout << "Enter the price for this customer's manicure : ";
cin >> maniIn;
}
cout << endl << endl;
cout << setw(35) << "SALES SUMMARY FOR " << name << endl;
cout << setw(49) << "================================" << endl;
manicure[maniPos++] = maniIn;
cout << setprecision(2);
while (hairStyle[ indexStyle ] != 0){
cout << setw(26) << "Style" << setw(7) << " : " << setw(3) << " $ ";
cout << setw(6) << hairStyle[indexStyle++] << endl;
}
while (hairColour[ indexColour ] != 0){
cout << setw(27) << "Colour" << setw(6) << " : " << setw(3) << " $ ";
cout << setw(6) << hairColour[indexColour++] << endl;
}
while (manicure[ indexManicure ] != 0){
cout << setw(29) << "Manicure" << setw(4) << " : " << setw(3) << " $ ";
cout << setw(6) << manicure[indexManicure++] << endl;
}
double totalIn = styleIn + colourIn + maniIn;
total[totalPos++] = totalIn;
while (total[ indexTotal ] != 0){
cout << setw(49) << "--------------------------------" << endl;
cout << setw(26) << "Total" << setw(7) << " : " << setw(3) << " $ ";
cout << total[indexTotal++] << endl;
cout << setw(49) << "================================" << endl;
cout << endl << endl;
}
cout << "Enter customer's Name: ";
cin >> name;
numberOfTimesEntered++;
}
i suspect it has something to do with my int indexStyle = 0, int indexColour = 0, int indexManicure = 0, int indexTotal = 0 ;but i cant seem to figure it out,.can anyone help me
double hairStyle[10] = {0};
double hairColour[10] = {0};
double manicure[10] = {0};
double total[10] = {0};
int stylepos = 0, int colourPos = 0, int maniPos = 0, int totalPos = 0;
int indexStyle = 0, int indexColour = 0, int indexManicure = 0, int indexTotal = 0 ;
int count = 0;
int numberOfTimesEntered = 0;
string name;
cout << "Enter customer's Name: ";
cin >> name;
while(name != "Exit")
{
cout << endl << endl;
cout << fixed << showpoint;
double styleIn;
cout << "Enter the price for this customer's hair style : ";
cin >> styleIn;
while(styleIn < 20.00 || styleIn > 200.00){
if(styleIn == 0){
break;
}
cout << "Price entered is out of range, Please re-enter price" << endl;
cout << "Enter the price for this customer's hair style : ";
cin >> styleIn;
}
hairStyle[stylepos++] = styleIn;
double colourIn;
cout << "Enter the price for this customer's hair colour : ";
cin >> colourIn;
while(colourIn < 20.00 || colourIn > 200.00){
if(colourIn == 0){
break;
}
cout << "Price entered is out of range, Please re-enter price" << endl;
cout << "Enter the price for this customer's hair colour : ";
cin >> colourIn;
}
hairColour[colourPos++] = colourIn;
double maniIn;
cout << "Enter the price for this customer's manicure : ";
cin >> maniIn;
while(maniIn < 20.00 || maniIn > 200.00){
if(maniIn == 0){
break;
}
cout << "Price entered is out of range, Please re-enter price" << endl;
cout << "Enter the price for this customer's manicure : ";
cin >> maniIn;
}
cout << endl << endl;
cout << setw(35) << "SALES SUMMARY FOR " << name << endl;
cout << setw(49) << "================================" << endl;
manicure[maniPos++] = maniIn;
cout << setprecision(2);
while (hairStyle[ indexStyle ] != 0){
cout << setw(26) << "Style" << setw(7) << " : " << setw(3) << " $ ";
cout << setw(6) << hairStyle[indexStyle++] << endl;
}
while (hairColour[ indexColour ] != 0){
cout << setw(27) << "Colour" << setw(6) << " : " << setw(3) << " $ ";
cout << setw(6) << hairColour[indexColour++] << endl;
}
while (manicure[ indexManicure ] != 0){
cout << setw(29) << "Manicure" << setw(4) << " : " << setw(3) << " $ ";
cout << setw(6) << manicure[indexManicure++] << endl;
}
double totalIn = styleIn + colourIn + maniIn;
total[totalPos++] = totalIn;
while (total[ indexTotal ] != 0){
cout << setw(49) << "--------------------------------" << endl;
cout << setw(26) << "Total" << setw(7) << " : " << setw(3) << " $ ";
cout << total[indexTotal++] << endl;
cout << setw(49) << "================================" << endl;
cout << endl << endl;
}
cout << "Enter customer's Name: ";
cin >> name;
numberOfTimesEntered++;
}
i suspect it has something to do with my int indexStyle = 0, int indexColour = 0, int indexManicure = 0, int indexTotal = 0 ;but i cant seem to figure it out,.can anyone help me