Advertisement
Guest User

Untitled

a guest
Jan 27th, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 19.20 KB | None | 0 0
  1. //
  2. //  main.cpp
  3. //  Vending machine
  4. //
  5. //  Created by Block D/H on 10/28/2014.
  6. //  Copyright (c) 2014 Russell. All rights reserved.
  7. //
  8. // A thing that holds food or drinks for the exchange of money,
  9. // People do not sell the food, a machine does.
  10. // EG. You put $5 in for a snickers, it will determine wheater
  11. // The amount is low, high or Exact
  12.  
  13. // Known limitations Letters beside the intro breaks the program
  14.  
  15. #include <iostream>
  16. using namespace std;
  17. #include <unistd.h>
  18. #include <string.h>
  19. #include <iomanip>
  20.  
  21.  
  22.  
  23. int main()
  24. {
  25.    
  26.     cout << setprecision(6);
  27.    
  28.     int item;
  29.     float amount;
  30.     char again = 'y';
  31.     string name;
  32.     string fresca;
  33.     float amountadd;
  34.     int admin;
  35.     float money = 100;
  36.     int snickers = 7;
  37.     int dorritos = 20;
  38.     int water = 10;
  39.     int burger = 2;
  40.     int ghost = 3;
  41.     int mars = 2;
  42.     int dew = 25;
  43.     int twizzler = 2;
  44.    
  45.    
  46.    
  47.    
  48.     while (again == 'y'){
  49.         cout << setprecision(4);
  50.        
  51.        
  52.         cout << "\n\n Hey you! What is your name!\n";
  53.         cin >> name;
  54.        
  55.         if (name == "Dawson"||name == "Stephan"){                                               //DAWSON FRESCA
  56.            
  57.             cout << "Would you like to buy a Fresca?\n";
  58.             cin >> fresca;
  59.            
  60.             if (fresca == "Yes"||fresca == "yes"){
  61.                 cout << "Let me give you some Fresca\n";
  62.                 sleep (1);
  63.                 cout << "But wait, let me hand deliver it to you\n";
  64.                 sleep (1);
  65.                 cout << "To your door...\n";
  66.                 sleep (1);
  67.                 cout << "And leave it by the DOOR!!!!\n";
  68.                 sleep (1);
  69.                 cout << "But wait... I might even bring food by your class too\n";
  70.                 sleep (1);
  71.                 cout << "\nThanks you for your purchase \nMr.Dawson, hope you like it\n";
  72.                
  73.                
  74.                
  75.             }
  76.            
  77.         }
  78.        
  79.         else if (name == "PlsNo"){
  80.             cout << "Welcome to the Admin screen, what would you like to know\n\n";             //admoon screen
  81.             sleep (1);
  82.             cout << "Quantity\n";
  83.             sleep (1);
  84.             cout << "Money\n";
  85.             cin >> admin;
  86.            
  87.             if (admin == 001){
  88.                 cout << "You have \n" <<snickers << " Snickers left\n";                         //you have stuff
  89.                 cout << dorritos << " Dorritos Left\n";
  90.                 cout << water << " Waters left\n";
  91.                 cout << burger << " Burgers left\n";
  92.                 cout << ghost << " Ghost pepepr chips left\n";
  93.                 cout << mars << " Mars bars left\n";
  94.                 cin >> again;
  95.             }
  96.            
  97.             else if (admin == 002){
  98.                 cout << "You have $" <<money;                                                   //you have money
  99.                 cin >> again;
  100.                
  101.             }
  102.         }
  103.        
  104.        
  105.         cout << "Hello " <<name<< " What do you want?\n";
  106.         cout << "   ________________________________________________\n";
  107.         cout << "   |                                               |\n";
  108.         cout << "   |                                               |\n";
  109.         cout << "   |  375 Snickers                                 |\n";
  110.         cout << "   |                                               |\n";
  111.         cout << "   |  289 Dorritos                     |  1 2   |  |\n";
  112.         cout << "   |                                   |  3 4   |  |\n";
  113.         cout << "   |  165 No Name Brand Water          |  5 6   |  |\n";
  114.         cout << "   |                                   |  7 8   |  |\n";
  115.         cout << "   |  569 Cheese Burger                |  9 0   |  |\n";
  116.         cout << "   |                                   |        |  |\n";
  117.         cout << "   |  666 Ghost Pepper Chips           |        |  |\n";
  118.         cout << "   |                                               |\n";
  119.         cout << "   |  325 Mars Bar                                 |\n";
  120.         cout << "   |                                               |\n";
  121.         cout << "   |  957 Mountain Dew                             |\n";
  122.         cout << "   |                                               |\n";
  123.         cout << "   |  421 Twizzlers                                |\n";
  124.         cout << "   |                                               |\n";
  125.         cout << "   |                                               |\n";
  126.         cout << "   |                                               |\n";
  127.         cout << "   | ______________________________________________|\n";
  128.         cout << "   |                                               |\n";
  129.         cout << "   |                                               |\n";
  130.         cout << "   |           _________                           |\n";
  131.         cout << "   |          |_________|                          |\n";
  132.         cout << "   |                                               |\n";
  133.         cout << "   |                                               |\n";
  134.         cout << "   |_______________________________________________|\n";
  135.         cin >> item;
  136.        
  137.        
  138.        
  139.        
  140.         if (snickers == 0){
  141.             cout << "Sorry out of stock";
  142.         }
  143.        
  144.         else if (item == 375){
  145.             cout << "Please insert $1.25 for a Snickers\n";        //Snickers
  146.             cin >> amount;
  147.            
  148.            
  149.            
  150.            
  151.             if (amount < 1.25){
  152.                 while (amount < 1.25){
  153.                     cout << "Please insert \n" <<1.25 - amount;         //If amount under 1.25
  154.                     cin >> amountadd;
  155.                     amount = amount + amountadd;
  156.                 }
  157.                 if (amount == 1.25){
  158.                     cout << "Thank you for your purchase\n";
  159.                     snickers = snickers - 1;
  160.                     money = money + 1.25;
  161.                    
  162.                    
  163.                    
  164.                 }
  165.                 else if (amount > 1.25){
  166.                     cout << "Thank you for your purchase, here is your change \n" <<amount - 1.25;
  167.                     cin >> again;
  168.                     money =  money + 1.25;
  169.                     snickers = snickers - 1;
  170.                 }
  171.                
  172.                 else if (amount == 1.25){
  173.                     cout << "\nThank you for your purchase " <<name;     //if amount 1.25 NAA;
  174.                     money = money + 1.25;
  175.                     snickers =  snickers - 1;
  176.                 }
  177.                
  178.                
  179.                
  180.                
  181.             }
  182.            
  183.             else if (amount > 1.25){
  184.                 cout << "You will recieve $" <<amount - 1.25;        //If amount over 1.25
  185.                 cout << "\nThank you for your purchase " <<name;
  186.                 money = money + 1.25;
  187.                 snickers =snickers - 1;
  188.             }
  189.            
  190.             else if (amount == 1.25){
  191.                 cout << "\nThank you for your purchase " <<name;          //If amount 1.25 YEE
  192.                 money = money + 1.25;
  193.                 snickers = snickers - 1;
  194.             }
  195.            
  196.            
  197.         }
  198.         else if (dorritos == 0 ){
  199.             cout << "Sorry, out of stock\n";
  200.         }
  201.         else if (item == 289){
  202.             cout << "Please insert $2.00 for Dorritos\n";           //Dorritos
  203.             cin >> amount;
  204.            
  205.             if (amount == 2.00){
  206.                 cout << "\nThank you for your purchase " <<name;
  207.                 dorritos = dorritos -1;
  208.                 money = money + 2.00;
  209.                
  210.             }
  211.            
  212.             else if (amount < 2.00){
  213.                 while (amount < 2.00){
  214.                     cout << "Please insert \n" <<2.00 - amount;         //If amount under 1.25
  215.                     cin >> amountadd;
  216.                     amount = amount + amountadd;
  217.                     money = money + 2.00;
  218.                    
  219.                     if (amount > 2.00){
  220.                         cout << "Thank you for your purchase, here is your change\n" <<amount - 2.00;
  221.                         dorritos = dorritos - 1;
  222.                         money = money + 2.00;
  223.                     }
  224.                    
  225.                 }
  226.                
  227.                
  228.                 if (amount == 2.00){
  229.                     cout << "\nThank you for your purchase " <<name;                            //thank you
  230.                     money = money + 2.00;
  231.                     dorritos =  dorritos - 1;
  232.                    
  233.                 }
  234.                 else if (amount > 2.00){
  235.                     cout << "Here is your change, $" <<amount -200;                             //change
  236.                    
  237.                 }
  238.             }
  239.            
  240.             else if (amount > 2.00){
  241.                 cout << "You will get \n" <<amount - 2.00;            //Over 2.00
  242.                 cout << "\nThank you for your purchase " <<name;
  243.                 dorritos = dorritos - 1;
  244.                 money = money + 2.00;
  245.                
  246.             }
  247.         }
  248.        
  249.        
  250.         else if (water == 0){
  251.             cout << "Sorry, out of stock\n";
  252.         }
  253.         else if (item == 165){
  254.             cout << "Please insert $1.10 for a No Name Brand Water\n";        //Water
  255.             cin >> amount;
  256.            
  257.             if (amount < 1.10){
  258.                 while (amount < 1.10){
  259.                     cout << "Please insert \n" <<1.10 - amount;         //If amount under 1.25
  260.                     cin >> amountadd;
  261.                     amount = amount + amountadd;
  262.                    
  263.                     if (amount > 1.10){
  264.                         cout << "Thank you for your purchase, here is your change\n" <<amount - 1.10;
  265.                         water = water - 1;
  266.                         money = money + 1.10;
  267.                     }
  268.                    
  269.                    
  270.                 }
  271.                
  272.                
  273.                
  274.             }
  275.            
  276.             else if (amount > 1.10){
  277.                 cout << "You will recieve $" <<amount - 1.10;        //If amount over 1.25
  278.                 cout << "\nThank you for your purchase " <<name;
  279.                 water = water - 1;
  280.                 money = money + 1.10;
  281.             }
  282.            
  283.             else if (amount == 1.10){
  284.                 cout << "\nThank you for your purchase " <<name;          //If amount 1.25 YEE
  285.                 water =  water - 1;
  286.                 money = money + 1.10;
  287.             }
  288.            
  289.            
  290.         }
  291.        
  292.         else if (burger == 0){
  293.             cout << "Sorry, out of stock\n";
  294.         }
  295.         else if (item == 569){
  296.             cout << "Please insert $4.45 for Bacon Cheese Burger\n";        //Cheese burger
  297.             cin >> amount;
  298.            
  299.             if (amount == 4.45){
  300.                 cout << "\nThank you for your purchase " <<name;           //if amount 4.45 YEE
  301.                 burger = burger - 1;
  302.                 money = money = 4.45;
  303.             }
  304.            
  305.             else if (amount > 4.45){
  306.                 cout << "You will recieve $" <<amount - 4.45;                //if Amount over 4.45
  307.                 cout << "\nThank you for your purchase " <<name;
  308.                 burger = burger - 1;
  309.                 money = money + 4.45;
  310.             }
  311.            
  312.             else if (amount < 4.45){
  313.                 while (amount < 4.45){
  314.                     cout << "Please insert \n" <<4.45 - amount;                 // if amount under 4.45
  315.                     cin >> amountadd;
  316.                     amount = amount + amountadd;
  317.                 }
  318.                
  319.                 if (amount == 4.45){
  320.                     cout << "\nThank you for your purchase " <<name;       //if amount 4.45 NUU
  321.                     burger =  burger - 1;
  322.                     money = money + 4.45;
  323.                 }
  324.                 else if (amount > 4.45){
  325.                     cout << "Here is your change, $" << amount - 4.45;;
  326.                     burger =  burger - 1;
  327.                     money = money + 4.45;
  328.                 }
  329.             }
  330.            
  331.         }
  332.        
  333.         else if (ghost == 0){
  334.             cout << "Sorry, out of stock\n";
  335.         }
  336.         else if (item == 666){                                              //ghost pepper  chips
  337.             cout << "You don't want those...\n";
  338.             sleep (1);
  339.             cout << "The devil is infused into those\n";
  340.             sleep (1);
  341.             cout << "I ate those ghost pepper chips one time...\n";
  342.             sleep (1);
  343.             cout << "I couldn't feel my mouth for 2 days\n";
  344.             sleep (1);
  345.             cout << "But if you want that please insert $5.25\n";
  346.             cin >> amount;
  347.            
  348.             if (amount == 5.25){
  349.                 cout << "Thank you for your purchase\n";                     //if amount 5.25 yee
  350.                 ghost = ghost - 1;
  351.                 money = money + 5.25;
  352.             }
  353.            
  354.             else if (amount < 5.25){
  355.                 while (amount < 5.25){
  356.                     cout << "Please insert $" << 5.25 - amount;                // if amount under 5.25 yee
  357.                     cin >> amountadd;
  358.                     amount = amount + amountadd;
  359.                 }
  360.                
  361.                 if (amount == 5.25){
  362.                     cout << "Thank you for your purchase\n";                //if amount 5.25 nuu
  363.                     ghost = ghost - 1;
  364.                     money = money + 5.25;
  365.                    
  366.                    
  367.                 }
  368.                
  369.                 else if (amount > 5.25){                                    // if amount under 5.25 nuu
  370.                     cout << "Here is your change, $" << amount - 5.25;
  371.                     ghost = ghost - 1;
  372.                     money = ghost + 5.25;
  373.                 }
  374.             }
  375.            
  376.             else if (amount > 5.25){
  377.                 cout << "You will recieve $" << amount - 5.25;             //if amount over 5.25
  378.                 cout << "Thank you for your purchase\n";
  379.                 ghost = ghost - 1;
  380.                 money = money + 5.25;
  381.             }
  382.            
  383.            
  384.         }
  385.        
  386.         else if (mars == 0){
  387.             cout << "Sorry, out of stock\n";
  388.         }
  389.         else if (item == 325) {
  390.             cout << "Please insert $1.25 for Mars bar\n";                   //mars bar
  391.             cin >> amount;
  392.            
  393.             if (amount == 1.25){
  394.                 cout << "Thank you for your purchase\n";                    //if amount 1.25 yee
  395.                 mars = mars - 1;
  396.                 money = money + 1.25;
  397.                
  398.             }
  399.             else if (amount < 1.25){
  400.                 while (amountadd < 1.25){
  401.                     cout << "Please insert $\n" << 1.25 - amount;
  402.                     cin >> amountadd;
  403.                     amount = amount + amountadd;                          //if amount under 1.25 yee
  404.                 }
  405.                
  406.                 if (amount == 1.25){
  407.                     cout << "Thank you for your purchase\n";                // if amount 1.25 nuuu
  408.                     mars =   mars - 1;
  409.                     money = money = 1.25;
  410.                    
  411.                    
  412.                 }
  413.                 else if (amount > 1.25){                                         // if amount under 1.25 nuu
  414.                     cout << "Here is your change, $" << amount - 1.25;
  415.                     mars =   mars - 1;
  416.                     money = money + 1.25;
  417.                 }
  418.             }
  419.             else if (amount > 1.25){                                        // if amount over 1.25
  420.                 cout << "You will recieve $\n" << amount - 1.25;
  421.                 cout << "Thank you for your purchase\n";
  422.                 mars = mars - 1;
  423.                 money = money + 1.25;
  424.             }
  425.         }
  426.        
  427.         else if (dew == 0){
  428.             cout << "Sorry, out of stock\n";
  429.         }
  430.         else if (item == 957){                                              // mountain dew
  431.             cout << "Please insert $1.00 for mountain dew\n";
  432.             cin >> amount;
  433.            
  434.             if (amount == 1.00){
  435.                 cout << "Thank you for your purchase\n";                    // if amount 1.10 yee
  436.                 dew = dew - 1;
  437.                 money = money + 1;
  438.             }
  439.             else if (amount > 1.00){
  440.                 cout << "You will recieve \n" << amount - 1.10;             // if amount over 1.10
  441.                 dew = dew - 1;
  442.                 money = money + 1;
  443.                
  444.             }
  445.            
  446.             else if (amount < 1.00){
  447.                 while (amount < 100){                                               // if amount under 1.10 yee
  448.                     cout << "Please insert " << 1.00 - amount;
  449.                     cin >> amount;
  450.                     amount = amount + amountadd;
  451.                 }
  452.                
  453.                 if (amount == 1.00){
  454.                     cout << "Thank you for your purchase\n";                // if amount 1.25 nuu
  455.                     dew =  dew - 1;
  456.                     money = money + 1;
  457.                 }
  458.                 else if(amount > 1.00){                                     // if amount under 1.15 nuu
  459.                     cout << "Here is your change, $" << amount - 1;
  460.                     dew = dew - 1;
  461.                     money = money + 1;
  462.                 }
  463.             }
  464.         }
  465.        
  466.         else if (twizzler == 0){
  467.             cout << "Sorry, out of stock\n";
  468.         }
  469.         else if (item == 421){                                              // Twizzlers
  470.             cout << "Please insert $3.25 for Twizzlers\n";
  471.             cin >> amount;
  472.            
  473.             if (amount == 3.25){
  474.                 cout << "Thank you for your purchase\n";                    // if amount 3.25 yee
  475.                 twizzler = twizzler - 1;
  476.                 money = money + 3.25;
  477.             }
  478.             else if (amount > 3.25){
  479.                 cout << "You will recieve \n" << amount - 3.25;             // if amount over 3.25
  480.                 twizzler = twizzler - 1;
  481.                 money = money + 3.25;
  482.                
  483.             }
  484.            
  485.             // if amount under 3.25 yee
  486.             if (amount < 3.25){
  487.                 while (amount < 3.25){
  488.                     cout << "Please insert \n" <<3.25 - amount;         //If amount under 3.25
  489.                     cin >> amountadd;
  490.                     amount = amount + amountadd;
  491.                 }
  492.                 if (amount == 3.25){
  493.                     cout << "Thank you for your purchase\n";
  494.                     snickers = snickers - 1;
  495.                     money = money + 3.25;
  496.                 }
  497.                 else if (amount > 3.25){
  498.                     cout << "Here is your change, $" <<amount - 3.25;
  499.                 }
  500.             }
  501.         }
  502.     }
  503.    
  504.    
  505.    
  506.    
  507.    
  508.     cout << "\nThank you for using this vending machine";                       // if retry = no
  509.    
  510.    
  511.    
  512.     return 0;
  513. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement