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 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
|
/*
PROGRAM NAME: LAB 3 - Convenience Store
PROGRAM DESCRIPTION: Simple simulation of a convenience store.
PROGRAMMER NAME: Chris Bottini
SOURCES USED: Boyd,
Ascii Generator from http://www.network-science.de/ascii/,
Absolute C++ 3rd adition
cplusplus.com.
DATE CREATED: 2/22/2010
LAST DATE MODIFIED:3/5/2010
*/
#include <iostream>
#include "CinReader.h"
using namespace std;
CinReader reader;
int main()
{
int soda = 0;
soda = 200;
int jerky = 0;
jerky = 100;
int toiletPaper = 0;
toiletPaper = 300;
int beer = 0;
beer = 800;
int cigarettes = 0;
cigarettes = 600;
int customerChoice = 0;
int moneyOwed = 0;
int customerMoney = 0;
customerMoney = 3000;
int moneyPaid = 0;
bool checkOut = false;
cout << " ## ## ######## ## ###### ####### ## ## ########" << endl;
cout << " ## ## ## ## ## ## ## ## ## ### ### ## " << endl;
cout << " ## ## ## ## ## ## ## ## #### #### ## " << endl;
cout << " ## ## ## ###### ## ## ## ## ## ### ## ###### " << endl;
cout << " ## ## ## ## ## ## ## ## ## ## ## " << endl;
cout << " ## ## ## ## ## ## ## ## ## ## ## ## " << endl;
cout << " ### ### ######## ######## ###### ####### ## ## ########" << endl << endl;
cout << " *********************************" << endl;
cout << " ***TO CHRIS'S CONVENIENCE STORE***" << endl;
cout << " *********************************" << endl << endl;
cout << " $$$$ YOU HAVE " << customerMoney << " PENNIES TO SPEND $$$$" << endl << endl;
cout << " ??? WHAT WOULD YOU LIKE TO PURCHASE TODAY ??? "<< endl << endl;
do
{
cout << " ITEMS: PRICE:" << endl << endl;
cout << " 1. Soda.............................200 Pennies" << endl;
cout << " 2. Jerky............................100 Pennies " << endl;
cout << " 3. Toilet Paper.....................300 Pennies" << endl;
cout << " 4. Beer.............................800 Pennies" << endl;
cout << " 5. Cigarettes.......................600 Pennies" << endl;
cout << " [0] ................Checkout...................." << endl << endl;
cout << "MAKE YOUR SELECTION" << endl << endl;
customerChoice = reader.readInt();
if (customerChoice > 5)
cout << endl << "You obviously do not know how to count. Pick items 1 through 5." << endl << endl;
switch (customerChoice)
{
case 1:
if (moneyOwed >= customerMoney)
{
cout << "!!!YOU HAVE NO MORE MONEY, YOU WILL NOT BE ALLOWED!!!" << endl;
cout << "!!!ANY MORE TRANSACTIONS, PLEASE CHECKOUT!!!" << endl;
}
else
{
moneyOwed = moneyOwed + soda;
cout << endl << "You have choosen a soda." << endl << endl;
cout << "You now owe me " << moneyOwed << " pennies" << endl;
cout << "Would you like to buy anything else!!!" << endl << endl << endl << endl;
}
break;
case 2:
if (moneyOwed >= customerMoney)
{
cout << "!!!YOU HAVE NO MORE MONEY, YOU WILL NOT BE ALLOWED!!!" << endl;
cout << "!!!ANY MORE TRANSACTIONS, PLEASE CHECKOUT!!!" << endl;
}
else
{
moneyOwed = moneyOwed + jerky;
cout << endl << "You have bought some Jerky." << endl << endl;
cout << "You now owe me " << moneyOwed << " pennies" << endl;
cout << "Would you like to buy anything else!!!" << endl << endl << endl << endl;
}
break;
case 3:
if (moneyOwed >= customerMoney)
{
cout << "!!!YOU HAVE NO MORE MONEY, YOU WILL NOT BE ALLOWED!!!" << endl;
cout << "!!!ANY MORE TRANSACTIONS, PLEASE CHECKOUT!!!" << endl;
}
else
{
moneyOwed = moneyOwed + toiletPaper;
cout << endl << "You have bought Toilet Paper." << endl << endl;
cout << "You now owe me " << moneyOwed << " pennies" << endl;
cout << "Would you like to buy anything else!!!" << endl << endl << endl << endl;
}
break;
case 4:
if (moneyOwed >= customerMoney)
{
cout << "!!!YOU HAVE NO MORE MONEY, YOU WILL NOT BE ALLOWED!!!" << endl;
cout << "!!!ANY MORE TRANSACTIONS, PLEASE CHECKOUT!!!" << endl;
}
else
{
moneyOwed = moneyOwed + beer;
cout << endl << "You have bought Beer." << endl << endl;
cout << "You now owe me " << moneyOwed << " pennies" << endl;
cout << "Would you like to buy anything else!!!" << endl << endl << endl << endl;
}
break;
case 5:
if (moneyOwed >= customerMoney)
{
cout << "!!!YOU HAVE NO MORE MONEY, YOU WILL NOT BE ALLOWED!!!" << endl;
cout << "!!!ANY MORE TRANSACTIONS, PLEASE CHECKOUT!!!" << endl;
}
else
{
moneyOwed = moneyOwed + cigarettes;
cout << endl << "You have bought some Cigarettes." << endl << endl;
cout << "You now owe me " << moneyOwed << " pennies" << endl;
cout << "Would you like to buy anything else!!!" << endl << endl << endl << endl;
}
break;
case 0:
cout << "You owe me " << moneyOwed << " pennies" << endl;
cout << "Enter penny amount to pay..." << endl;
moneyPaid = reader.readInt();
// moneyOwed = moneyOwed - moneyPaid;
if (moneyOwed == moneyPaid)
{
checkOut = true;
cout << "Thank you come again" << endl;
}
else if(moneyOwed > moneyPaid)
{
moneyOwed = moneyOwed - moneyPaid;
cout << " THATS NOT ENOUGH PARTNER, DON'T MAKE ME GET MY SHOTTIE " << endl;
cout << " YOU STILL OWE ME " << moneyOwed << " PENNIES" << endl << endl;
cout << " Enter Amount to pay..." << endl;
moneyPaid = reader.readInt();
}
else
{
cout << " THATS TOO MUCH, YOU ONLY OWE ME " << moneyOwed << " PENNIES" << endl;
cout << "Enter Amount to pay..." << endl;
moneyPaid = reader.readInt();
}
break;
}
} while (checkOut == false);
return 0;
}
|