Advertisement
Guest User

flehmesehm

a guest
Sep 16th, 2014
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1.  
  2.  
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. int main(int argc, const char * argv[])
  7. {
  8.  
  9.  
  10. cout.setf(ios::fixed);
  11. cout.setf(ios::showpoint);
  12. cout.precision(2);
  13.  
  14.  
  15. char userinput;
  16.  
  17. cout << "A packet of candie costs $1.50. You have inserted $0.00. Please insert coins:";
  18. cin >> userinput;
  19.  
  20.  
  21.  
  22.  
  23. if (userinput = 'n')
  24. {
  25. userinput = 0.05;
  26. }
  27.  
  28. else if (userinput = 'd')
  29. {
  30. userinput = 0.10;
  31. }
  32.  
  33. else if (userinput = 'q')
  34. {
  35. userinput = 0.25;
  36. }
  37.  
  38. else if (userinput = 'D')
  39. {
  40. userinput = 1.00;
  41. }
  42.  
  43. else
  44. {
  45. cout << "'" << userinput << "' is not a valid coin.";
  46. }
  47.  
  48. cout << userinput;
  49.  
  50. /*int i;
  51.  
  52. for (i = 0; i <= userinput; i++)
  53. {
  54.  
  55. cout << "A packet of candie costs $1.50. You have inserted $" << userinput << ".";
  56. cout << "Please insert coins: ";
  57. cin >> userinput;
  58.  
  59. userinput = userinput + userinput;
  60. }*/
  61.  
  62.  
  63. return (0);
  64.  
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement