Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.cpp
- // Vending machine
- //
- // Created by Block D/H on 10/28/2014.
- // Copyright (c) 2014 Russell. All rights reserved.
- //
- // A thing that holds food or drinks for the exchange of money,
- // People do not sell the food, a machine does.
- // EG. You put $5 in for a snickers, it will determine wheater
- // The amount is low, high or Exact
- // Known limitations Letters beside the intro breaks the program
- #include <iostream>
- using namespace std;
- #include <unistd.h>
- #include <string.h>
- #include <iomanip>
- int main()
- {
- cout << setprecision(6);
- int item;
- float amount;
- char again = 'y';
- string name;
- string fresca;
- float amountadd;
- int admin;
- float money = 100;
- int snickers = 7;
- int dorritos = 20;
- int water = 10;
- int burger = 2;
- int ghost = 3;
- int mars = 2;
- int dew = 25;
- int twizzler = 2;
- while (again == 'y'){
- cout << setprecision(4);
- cout << "\n\n Hey you! What is your name!\n";
- cin >> name;
- if (name == "Dawson"||name == "Stephan"){ //DAWSON FRESCA
- cout << "Would you like to buy a Fresca?\n";
- cin >> fresca;
- if (fresca == "Yes"||fresca == "yes"){
- cout << "Let me give you some Fresca\n";
- sleep (1);
- cout << "But wait, let me hand deliver it to you\n";
- sleep (1);
- cout << "To your door...\n";
- sleep (1);
- cout << "And leave it by the DOOR!!!!\n";
- sleep (1);
- cout << "But wait... I might even bring food by your class too\n";
- sleep (1);
- cout << "\nThanks you for your purchase \nMr.Dawson, hope you like it\n";
- }
- }
- else if (name == "PlsNo"){
- cout << "Welcome to the Admin screen, what would you like to know\n\n"; //admoon screen
- sleep (1);
- cout << "Quantity\n";
- sleep (1);
- cout << "Money\n";
- cin >> admin;
- if (admin == 001){
- cout << "You have \n" <<snickers << " Snickers left\n"; //you have stuff
- cout << dorritos << " Dorritos Left\n";
- cout << water << " Waters left\n";
- cout << burger << " Burgers left\n";
- cout << ghost << " Ghost pepepr chips left\n";
- cout << mars << " Mars bars left\n";
- cin >> again;
- }
- else if (admin == 002){
- cout << "You have $" <<money; //you have money
- cin >> again;
- }
- }
- cout << "Hello " <<name<< " What do you want?\n";
- cout << " ________________________________________________\n";
- cout << " | |\n";
- cout << " | |\n";
- cout << " | 375 Snickers |\n";
- cout << " | |\n";
- cout << " | 289 Dorritos | 1 2 | |\n";
- cout << " | | 3 4 | |\n";
- cout << " | 165 No Name Brand Water | 5 6 | |\n";
- cout << " | | 7 8 | |\n";
- cout << " | 569 Cheese Burger | 9 0 | |\n";
- cout << " | | | |\n";
- cout << " | 666 Ghost Pepper Chips | | |\n";
- cout << " | |\n";
- cout << " | 325 Mars Bar |\n";
- cout << " | |\n";
- cout << " | 957 Mountain Dew |\n";
- cout << " | |\n";
- cout << " | 421 Twizzlers |\n";
- cout << " | |\n";
- cout << " | |\n";
- cout << " | |\n";
- cout << " | ______________________________________________|\n";
- cout << " | |\n";
- cout << " | |\n";
- cout << " | _________ |\n";
- cout << " | |_________| |\n";
- cout << " | |\n";
- cout << " | |\n";
- cout << " |_______________________________________________|\n";
- cin >> item;
- if (snickers == 0){
- cout << "Sorry out of stock";
- }
- else if (item == 375){
- cout << "Please insert $1.25 for a Snickers\n"; //Snickers
- cin >> amount;
- if (amount < 1.25){
- while (amount < 1.25){
- cout << "Please insert \n" <<1.25 - amount; //If amount under 1.25
- cin >> amountadd;
- amount = amount + amountadd;
- }
- if (amount == 1.25){
- cout << "Thank you for your purchase\n";
- snickers = snickers - 1;
- money = money + 1.25;
- }
- else if (amount > 1.25){
- cout << "Thank you for your purchase, here is your change \n" <<amount - 1.25;
- cin >> again;
- money = money + 1.25;
- snickers = snickers - 1;
- }
- else if (amount == 1.25){
- cout << "\nThank you for your purchase " <<name; //if amount 1.25 NAA;
- money = money + 1.25;
- snickers = snickers - 1;
- }
- }
- else if (amount > 1.25){
- cout << "You will recieve $" <<amount - 1.25; //If amount over 1.25
- cout << "\nThank you for your purchase " <<name;
- money = money + 1.25;
- snickers =snickers - 1;
- }
- else if (amount == 1.25){
- cout << "\nThank you for your purchase " <<name; //If amount 1.25 YEE
- money = money + 1.25;
- snickers = snickers - 1;
- }
- }
- else if (dorritos == 0 ){
- cout << "Sorry, out of stock\n";
- }
- else if (item == 289){
- cout << "Please insert $2.00 for Dorritos\n"; //Dorritos
- cin >> amount;
- if (amount == 2.00){
- cout << "\nThank you for your purchase " <<name;
- dorritos = dorritos -1;
- money = money + 2.00;
- }
- else if (amount < 2.00){
- while (amount < 2.00){
- cout << "Please insert \n" <<2.00 - amount; //If amount under 1.25
- cin >> amountadd;
- amount = amount + amountadd;
- money = money + 2.00;
- if (amount > 2.00){
- cout << "Thank you for your purchase, here is your change\n" <<amount - 2.00;
- dorritos = dorritos - 1;
- money = money + 2.00;
- }
- }
- if (amount == 2.00){
- cout << "\nThank you for your purchase " <<name; //thank you
- money = money + 2.00;
- dorritos = dorritos - 1;
- }
- else if (amount > 2.00){
- cout << "Here is your change, $" <<amount -200; //change
- }
- }
- else if (amount > 2.00){
- cout << "You will get \n" <<amount - 2.00; //Over 2.00
- cout << "\nThank you for your purchase " <<name;
- dorritos = dorritos - 1;
- money = money + 2.00;
- }
- }
- else if (water == 0){
- cout << "Sorry, out of stock\n";
- }
- else if (item == 165){
- cout << "Please insert $1.10 for a No Name Brand Water\n"; //Water
- cin >> amount;
- if (amount < 1.10){
- while (amount < 1.10){
- cout << "Please insert \n" <<1.10 - amount; //If amount under 1.25
- cin >> amountadd;
- amount = amount + amountadd;
- if (amount > 1.10){
- cout << "Thank you for your purchase, here is your change\n" <<amount - 1.10;
- water = water - 1;
- money = money + 1.10;
- }
- }
- }
- else if (amount > 1.10){
- cout << "You will recieve $" <<amount - 1.10; //If amount over 1.25
- cout << "\nThank you for your purchase " <<name;
- water = water - 1;
- money = money + 1.10;
- }
- else if (amount == 1.10){
- cout << "\nThank you for your purchase " <<name; //If amount 1.25 YEE
- water = water - 1;
- money = money + 1.10;
- }
- }
- else if (burger == 0){
- cout << "Sorry, out of stock\n";
- }
- else if (item == 569){
- cout << "Please insert $4.45 for Bacon Cheese Burger\n"; //Cheese burger
- cin >> amount;
- if (amount == 4.45){
- cout << "\nThank you for your purchase " <<name; //if amount 4.45 YEE
- burger = burger - 1;
- money = money = 4.45;
- }
- else if (amount > 4.45){
- cout << "You will recieve $" <<amount - 4.45; //if Amount over 4.45
- cout << "\nThank you for your purchase " <<name;
- burger = burger - 1;
- money = money + 4.45;
- }
- else if (amount < 4.45){
- while (amount < 4.45){
- cout << "Please insert \n" <<4.45 - amount; // if amount under 4.45
- cin >> amountadd;
- amount = amount + amountadd;
- }
- if (amount == 4.45){
- cout << "\nThank you for your purchase " <<name; //if amount 4.45 NUU
- burger = burger - 1;
- money = money + 4.45;
- }
- else if (amount > 4.45){
- cout << "Here is your change, $" << amount - 4.45;;
- burger = burger - 1;
- money = money + 4.45;
- }
- }
- }
- else if (ghost == 0){
- cout << "Sorry, out of stock\n";
- }
- else if (item == 666){ //ghost pepper chips
- cout << "You don't want those...\n";
- sleep (1);
- cout << "The devil is infused into those\n";
- sleep (1);
- cout << "I ate those ghost pepper chips one time...\n";
- sleep (1);
- cout << "I couldn't feel my mouth for 2 days\n";
- sleep (1);
- cout << "But if you want that please insert $5.25\n";
- cin >> amount;
- if (amount == 5.25){
- cout << "Thank you for your purchase\n"; //if amount 5.25 yee
- ghost = ghost - 1;
- money = money + 5.25;
- }
- else if (amount < 5.25){
- while (amount < 5.25){
- cout << "Please insert $" << 5.25 - amount; // if amount under 5.25 yee
- cin >> amountadd;
- amount = amount + amountadd;
- }
- if (amount == 5.25){
- cout << "Thank you for your purchase\n"; //if amount 5.25 nuu
- ghost = ghost - 1;
- money = money + 5.25;
- }
- else if (amount > 5.25){ // if amount under 5.25 nuu
- cout << "Here is your change, $" << amount - 5.25;
- ghost = ghost - 1;
- money = ghost + 5.25;
- }
- }
- else if (amount > 5.25){
- cout << "You will recieve $" << amount - 5.25; //if amount over 5.25
- cout << "Thank you for your purchase\n";
- ghost = ghost - 1;
- money = money + 5.25;
- }
- }
- else if (mars == 0){
- cout << "Sorry, out of stock\n";
- }
- else if (item == 325) {
- cout << "Please insert $1.25 for Mars bar\n"; //mars bar
- cin >> amount;
- if (amount == 1.25){
- cout << "Thank you for your purchase\n"; //if amount 1.25 yee
- mars = mars - 1;
- money = money + 1.25;
- }
- else if (amount < 1.25){
- while (amountadd < 1.25){
- cout << "Please insert $\n" << 1.25 - amount;
- cin >> amountadd;
- amount = amount + amountadd; //if amount under 1.25 yee
- }
- if (amount == 1.25){
- cout << "Thank you for your purchase\n"; // if amount 1.25 nuuu
- mars = mars - 1;
- money = money = 1.25;
- }
- else if (amount > 1.25){ // if amount under 1.25 nuu
- cout << "Here is your change, $" << amount - 1.25;
- mars = mars - 1;
- money = money + 1.25;
- }
- }
- else if (amount > 1.25){ // if amount over 1.25
- cout << "You will recieve $\n" << amount - 1.25;
- cout << "Thank you for your purchase\n";
- mars = mars - 1;
- money = money + 1.25;
- }
- }
- else if (dew == 0){
- cout << "Sorry, out of stock\n";
- }
- else if (item == 957){ // mountain dew
- cout << "Please insert $1.00 for mountain dew\n";
- cin >> amount;
- if (amount == 1.00){
- cout << "Thank you for your purchase\n"; // if amount 1.10 yee
- dew = dew - 1;
- money = money + 1;
- }
- else if (amount > 1.00){
- cout << "You will recieve \n" << amount - 1.10; // if amount over 1.10
- dew = dew - 1;
- money = money + 1;
- }
- else if (amount < 1.00){
- while (amount < 100){ // if amount under 1.10 yee
- cout << "Please insert " << 1.00 - amount;
- cin >> amount;
- amount = amount + amountadd;
- }
- if (amount == 1.00){
- cout << "Thank you for your purchase\n"; // if amount 1.25 nuu
- dew = dew - 1;
- money = money + 1;
- }
- else if(amount > 1.00){ // if amount under 1.15 nuu
- cout << "Here is your change, $" << amount - 1;
- dew = dew - 1;
- money = money + 1;
- }
- }
- }
- else if (twizzler == 0){
- cout << "Sorry, out of stock\n";
- }
- else if (item == 421){ // Twizzlers
- cout << "Please insert $3.25 for Twizzlers\n";
- cin >> amount;
- if (amount == 3.25){
- cout << "Thank you for your purchase\n"; // if amount 3.25 yee
- twizzler = twizzler - 1;
- money = money + 3.25;
- }
- else if (amount > 3.25){
- cout << "You will recieve \n" << amount - 3.25; // if amount over 3.25
- twizzler = twizzler - 1;
- money = money + 3.25;
- }
- // if amount under 3.25 yee
- if (amount < 3.25){
- while (amount < 3.25){
- cout << "Please insert \n" <<3.25 - amount; //If amount under 3.25
- cin >> amountadd;
- amount = amount + amountadd;
- }
- if (amount == 3.25){
- cout << "Thank you for your purchase\n";
- snickers = snickers - 1;
- money = money + 3.25;
- }
- else if (amount > 3.25){
- cout << "Here is your change, $" <<amount - 3.25;
- }
- }
- }
- }
- cout << "\nThank you for using this vending machine"; // if retry = no
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement