Advertisement
okelikai

campusShop

Oct 16th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <fstream>
  4. #include <string>
  5. #include <iomanip>
  6. #include <limits>
  7. #include <stdio.h>
  8. #include <string.h>
  9. using namespace std;
  10.  
  11.  
  12. int main() {
  13.     int const SPENDING_MONEY = 200;
  14.     string prompt, money_stat, buy, inv, crt, shp, item;
  15.     int cin1, choice2, choice3, choice4, j, n;
  16.     double current_money, price;
  17.     size_t finder;
  18.    
  19.     prompt = "\n\nMENU:\n1. Buy\n2. Return\n3. List\n4. Quit\n>";
  20.    
  21.     current_money = SPENDING_MONEY;
  22.    
  23.     fstream inventory;
  24.     fstream receipt;
  25.     fstream the_shop;
  26.     j = 1;
  27.    
  28.     cout << "\n\n\n\nWelcome to the online Prep Store! [Be sure to enter corresponding digit]\n";
  29.    
  30.     while(j == 1){
  31.     cout << "\n\n\n\n\n";
  32.     cout << setw(40) << "Money: " << current_money;  
  33.     cout << prompt;
  34.     cin >> cin1;
  35.  
  36.  
  37.     switch(cin1) {
  38.         case 1:
  39.             inventory.open("txt/inventory.txt");
  40.                 while(!inventory.eof()){
  41.                     getline(inventory, inv);
  42.                     cout << inv << "\n";
  43.                 }
  44.             inventory.close();
  45.            
  46.             cout << "Enter item that you would like to buy\n>";
  47.             cin >> buy;
  48.            
  49.             break;
  50.         case 2:
  51.             if(receipt.fail()) {
  52.                 cout << "sorry but you got to buy something first";
  53.                 break;
  54.             }
  55.             else {
  56.                 cout << "What item would you like to return?\n>";
  57.                 cin >> item;
  58.                 receipt.open("txt/receipt.txt");
  59.                 receipt.close();
  60.                 break;
  61.             }
  62.             break;
  63.         case 3:
  64.             cout << "What list would you like to be given?\n1.Inventory\n2.Cart\n>";
  65.             cin >> choice3;
  66.             if(choice3 == 1) {
  67.                 the_shop.open("txt/shop.txt");
  68.                 n = 0;
  69.                     while(!the_shop.eof()){
  70.                         getline(the_shop, shp);
  71.                         cout << inv << "\n";
  72.                         n += 1;    
  73.                     }
  74.                 inventory.close();
  75.                 break;
  76.             }
  77.            
  78.             else if(choice3 == 2) {
  79.                 if (receipt.fail()) {
  80.                     cout << "Sorry bud, nothing on receipt";
  81.                     break;
  82.                 }
  83.                 else {
  84.                     receipt.open("txt/receipt.txt");
  85.                     while(!receipt.eof()){
  86.                         getline(receipt, crt);
  87.                         cout << crt << "\n";
  88.                     }
  89.                     receipt.close();
  90.                     break;
  91.                 }
  92.             }
  93.             else {
  94.                 break;
  95.             }
  96.            
  97.             break;
  98.            
  99.         case 4:
  100.             cout << "Leaving with new swag?\n1.yes\n2.no\n>";
  101.             cin >> choice4;
  102.             if(choice4 == 1) {
  103.                 if(receipt.fail()) {
  104.                     cout << "Sorry bud, nothing on receipt";
  105.                     break;
  106.                 }
  107.                 else {
  108.                     while(!receipt.eof()){
  109.                     getline(receipt, crt);
  110.                     cout << crt << "\n";
  111.                     break;
  112.                     }
  113.                 }
  114.                
  115.             } else if(choice4 == 2) {
  116.                 j = j - 1;
  117.                 break;
  118.                
  119.             }
  120.             else {
  121.                 cout << "Not a choice\n";
  122.             }
  123.             break;
  124.            
  125.         default:
  126.             cout << "Sorry not a choice\n\n";
  127.             break;
  128.         }
  129.     }
  130.  
  131. cout << "Well skrt skrt outta here boi";
  132.  return 0;  
  133. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement