I am trying to code(c++) a count and sum off of a menu eg. if I ordered 2-B's, 1-A and 3-C's the amount would be 27. My code below only shows 21.25 which seems that it isn't adding the first input. Any suggestions on how I wrote my code?
Thanks for the help
Bill
Code:#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main( )
{
//declare variables
char comboType = ' ';
double comboPrice = 0.0;
double orderTotal = 0.0;
//input data
cout << "Enter item ordered [A/B/C/D] or T to calculate total: ";
cin >> comboType;
comboType = toupper(comboType);
while (comboType != 'T')
{
cout << "Enter item ordered [A/B/C/D] or T to calculate total: ";
cin >> comboType;
orderTotal += comboPrice;
switch (comboType)
{
case 'A':
comboPrice = 4.25;
break;
case 'B':
comboPrice = 5.75;
break;
case 'C':
comboPrice = 5.25;
break;
case 'D':
comboPrice = 3.75;
break;
//end switch
}
// end while
}
//display output
if (comboType = 'T')
{
cout << "Please pay this amount: " << orderTotal << endl;
}
else
cout << "No items ordered!" << endl;
system("pause");
return 0;
}