Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <fstream>
- #include <string>
- #include <iomanip>
- #include <limits>
- #include <stdio.h>
- #include <string.h>
- using namespace std;
- int main() {
- int const SPENDING_MONEY = 200;
- string prompt, money_stat, buy, inv, crt, shp, item;
- int cin1, choice2, choice3, choice4, j, n;
- double current_money, price;
- size_t finder;
- prompt = "\n\nMENU:\n1. Buy\n2. Return\n3. List\n4. Quit\n>";
- current_money = SPENDING_MONEY;
- fstream inventory;
- fstream receipt;
- fstream the_shop;
- j = 1;
- cout << "\n\n\n\nWelcome to the online Prep Store! [Be sure to enter corresponding digit]\n";
- while(j == 1){
- cout << "\n\n\n\n\n";
- cout << setw(40) << "Money: " << current_money;
- cout << prompt;
- cin >> cin1;
- switch(cin1) {
- case 1:
- inventory.open("txt/inventory.txt");
- while(!inventory.eof()){
- getline(inventory, inv);
- cout << inv << "\n";
- }
- inventory.close();
- cout << "Enter item that you would like to buy\n>";
- cin >> buy;
- break;
- case 2:
- if(receipt.fail()) {
- cout << "sorry but you got to buy something first";
- break;
- }
- else {
- cout << "What item would you like to return?\n>";
- cin >> item;
- receipt.open("txt/receipt.txt");
- receipt.close();
- break;
- }
- break;
- case 3:
- cout << "What list would you like to be given?\n1.Inventory\n2.Cart\n>";
- cin >> choice3;
- if(choice3 == 1) {
- the_shop.open("txt/shop.txt");
- n = 0;
- while(!the_shop.eof()){
- getline(the_shop, shp);
- cout << inv << "\n";
- n += 1;
- }
- inventory.close();
- break;
- }
- else if(choice3 == 2) {
- if (receipt.fail()) {
- cout << "Sorry bud, nothing on receipt";
- break;
- }
- else {
- receipt.open("txt/receipt.txt");
- while(!receipt.eof()){
- getline(receipt, crt);
- cout << crt << "\n";
- }
- receipt.close();
- break;
- }
- }
- else {
- break;
- }
- break;
- case 4:
- cout << "Leaving with new swag?\n1.yes\n2.no\n>";
- cin >> choice4;
- if(choice4 == 1) {
- if(receipt.fail()) {
- cout << "Sorry bud, nothing on receipt";
- break;
- }
- else {
- while(!receipt.eof()){
- getline(receipt, crt);
- cout << crt << "\n";
- break;
- }
- }
- } else if(choice4 == 2) {
- j = j - 1;
- break;
- }
- else {
- cout << "Not a choice\n";
- }
- break;
- default:
- cout << "Sorry not a choice\n\n";
- break;
- }
- }
- cout << "Well skrt skrt outta here boi";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement