Apr 1, 2016 at 11:11pm Apr 1, 2016 at 11:11pm UTC
my code is acting like a hydra... get rid of one problem, 2 more take its place. if i put in one order of each variable its fine but if i do any combo that leaves out one, it still displays that drink with some weird exponential number. no clue where to start anymore, but the total that displays the price is unaffected and the total that displays the number of drinks ordered is unaffected. help is greatly appreciated. once i can get the issue fixed i will be modify it to do this
case 'C':
case 'c':
cout << "Thank you. You have ordered the Coffee.\n" << endl;
coffee++;
break;
the code displayed is the most successful so far.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
double coffee;
double juice;
double soda;
double tea;
double Manager_Special;
char choice;
int total_drinks;
double total;
do
{
cout << "Welcome to My Coffee Shop! We Offer:" << endl;
cout << "C - Coffee ($1.89)" << endl;
cout << "J - Juice ($2.99)" << endl;
cout << "S - Soda ($3.99)" << endl;
cout << "T - Tea ($4.99)" << endl;
cout << "M - Manager Special ($5.99)" << endl;
cout << "X - Done With Placing Order" << endl;
cout << "What drink would you like? Select C, J, S, T, M (or X to finish with order)" <<endl;
cin >> choice;
switch (choice)
{
case 'C' :
cout << "Thank you. You have ordered the Coffee.\n" << endl;
coffee++;
break ;
case 'c' :
cout << "Thank you. You have ordered the Coffee.\n" << endl;
coffee++;
break ;
case 'J' :
cout << "Thank you. You have ordered the Juice.\n" << endl;
juice++;
break ;
case 'j' :
cout << "Thank you. You have ordered the Juice.\n" << endl;
juice++;
break ;
case 'S' :
cout << "Thank you. You have ordered the Soda.\n" << endl;
soda++;
break ;
case 's' :
soda++;
cout << "Thank you. You have ordered the Soda.\n" << endl;
break ;
case 'T' :
cout << "Thank you. You have ordered the Tea.\n" << endl;
tea++;
break ;
case 't' :
cout << "Thank you. You have ordered the Tea.\n" << endl;
tea++;
break ;
case 'M' :
cout << "Thank you. You have order the Manager Special.\n" << endl;
Manager_Special++;
break ;
case 'm' :
cout << "Thank you. You have order the Manager Special.\n" << endl;
Manager_Special++;
break ;
case 'X' :
break ;
case 'x' :
break ;
default :
cout << "You did not enter C, J, S, T, M, or X!\n" << endl;
break ;
}
}
while (choice != 'x' && choice != 'X' );
total_drinks = coffee + juice + soda + tea + Manager_Special;
total = (coffee * 1.89) + (juice * 2.99) + (soda * 3.99) + (tea * 4.99) + (Manager_Special * 5.99);
cout << "You have ordered " << total_drinks << " drinks." << " Here is your order: " << endl;
cout << "Beverage" << setw(25) << "Quantity" << endl;
if (coffee > 0)
{
cout << "Coffee" << setw(20) << coffee << endl;
}
if (juice > 0)
{
cout << "Juice" << setw(21) << juice << endl;
}
if (soda > 0)
{
cout << "Soda" << setw(22) << soda << endl;
}
if (tea > 0)
{
cout << "Tea" << setw(23)<< tea << endl;
}
if (Manager_Special > 0)
{
cout << "Manager Special" << setw(11) << Manager_Special << endl;
}
cout << "Total: " << total << endl;
cout << "Done. Have a great day!" << endl;
return 0;
}
Last edited on Apr 1, 2016 at 11:19pm Apr 1, 2016 at 11:19pm UTC
Apr 2, 2016 at 12:47am Apr 2, 2016 at 12:47am UTC
Initialize variables. Pay attention to warnings generated by the compiler.
Apr 2, 2016 at 3:16pm Apr 2, 2016 at 3:16pm UTC
i solved that issue... this is a new problem but still in the same area. and there was no warnings from the compiler. and now its fixed... now i feel like an idiot. it was initialize variables.