Facebook
From jarek, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 55
  1. #include <iostream>
  2. #include <string.h>
  3. #include <cstdlib>
  4. #include <conio.h>
  5. #include <Windows.h>
  6. using namespace std;
  7. void ChooseAcarMenu();
  8. void AfterSuccessfulLogin()
  9. {
  10.     int x, accountBalance,paidinamount,number;
  11.     accountBalance = 15000;
  12.  
  13.    do
  14.     {
  15.         cout << "Welcome to the ATM cash deposit machine \n"
  16.             << "Choose one of the options: \n"
  17.             << "\n1. Checking account status."
  18.             << "\n2. Deposit money."
  19.             << "\n3.Redirect you to choose a car"
  20.             << "\nPlease enter the number:";
  21.         cin >> x; system("cls");
  22.  
  23.         switch (x)
  24.         {
  25.         case 1:
  26.             cout << "Checking account balance ..."; Sleep(1000);
  27.             cout << "\nPlease wait ..."; Sleep(1000); system("cls");
  28.             cout << "Your account balance is: " << accountBalance + paidinamount << " zl"; Sleep(1000); system("cls");
  29.             cout << "Option:"
  30.                 << "\n1. Return to main menu"
  31.                 << "\n2. Exit";
  32.             cout << "\n\nEnter a number ";
  33.             cin >> number;
  34.  
  35.             if (number == 2)
  36.             {
  37.                 system("cls");
  38.                 cout << "Exit.\n"; Sleep(2000); exit(0);
  39.             }
  40.             else
  41.             {
  42.                 system("cls");
  43.                 cout << "In a moment you will be redirected to the main menu ..."; Sleep(2000); system("cls"); break;
  44.             }
  45.  
  46.         case 2:
  47.             cout << "What amount do you want to pay? \n";
  48.             cout << "Amount to be paid:";
  49.             cin >> paidinamount; system("cls");
  50.  
  51.             if ((paidinamount >= 1) && (paidinamount <= 1000000))
  52.             {
  53.                 system("cls");
  54.                 cout << "Please put cash. There will be a payment in a moment " << paidinamount << " zl\n"; Sleep(2000); system("cls");
  55.                 cout << "Please wait..."; Sleep(2000); system("cls");
  56.                 cout << "Your money has been paid.\n";
  57.                 cout << "The current account balance is " << accountBalance + paidinamount << "zl"; Sleep(2000); system("cls");
  58.                 cout << "Thank you for using the services."; Sleep(2000); system("cls");
  59.                 cout << "In a moment you will be redirected to the main menu ..."; Sleep(2000); system("cls"); break;
  60.             }
  61.             else
  62.             {
  63.                 cout << "You have entered an incorrect number or amount is not supported by our system."; Sleep(2000); system("cls");
  64.                 cout << "Option:"
  65.                     << "\n1. Return to main menu"
  66.                     << "\n2. Exit";
  67.                 cout << "\n\nEnter a number ";
  68.                 cin >> number;
  69.             }
  70.             if (number == 2)
  71.             {
  72.                 system("cls");
  73.                 cout << "Exit.\n"; Sleep(2000); exit(0);
  74.             }
  75.             else
  76.             {
  77.                 system("cls");
  78.                 cout << "In a moment you will be redirected to the main menu ... "; Sleep(2000); system("cls"); break;
  79.             }
  80.         case 3:
  81.         {
  82.      
  83.             cout << "Thank you for using our services" << endl;
  84.             ChooseAcarMenu();
  85.         }
  86.  
  87.         }
  88.  
  89.    } while (x != 3);
  90.  
  91. }
  92. void LogToAccount()
  93. {
  94.     string login = "12345";
  95.     string pin = "1234";
  96.     string lo; //login auxiliary variable
  97.     string pn; //pin auxiliary variable
  98.     cout << "Welcome to the bank!" << endl;
  99.     cout << "Please login to the account" << endl;
  100.     cout << "Enter a login: ";
  101.     cin >> lo;
  102.     if (lo != login)
  103.     {
  104.         cout << "BAD LOGIN!" << endl;
  105.         cout << "Try again!" << endl;
  106.         system("cls");
  107.         LogToAccount();
  108.     }
  109.     else if (lo == login)
  110.     {
  111.         cout << "pin:";
  112.         cin >> pn;
  113.         if (pn != pin)
  114.         {
  115.             cout << "bad pin!" << endl;
  116.             cout << "TRY AGAIN!" << endl;
  117.             system("cls");
  118.             LogToAccount();
  119.         }
  120.         else
  121.         {
  122.             cout << "Logged in";
  123.             system("cls");
  124.             AfterSuccessfulLogin();
  125.         }
  126.     }
  127.  
  128. }
  129. void EnoughMoney()
  130. {
  131.     string answer = "Yes";
  132.     cout << "Do you have enough money in the bank?(Yes/No)" << endl;
  133.     cin >> answer;
  134.     if (answer != "Yes")
  135.     {
  136.         cout << "You must deposit money!" << endl;
  137.         system("cls");
  138.         LogToAccount();
  139.     }
  140.     else if (answer == "Yes")
  141.     {
  142.         cout << "You buy this car! Congratulations" << endl;
  143.     }
  144. }
  145. struct car
  146. {
  147.     car(string m, string mo, string ye, string ca, string HP, string pr, string ft);
  148.     void printToStdout();
  149. private:
  150.     string mark;//marka
  151.     string model;//model
  152.     string yearbook;//rocznik
  153.     string capacity;//pojemnosc
  154.     string price;//cena
  155.     string Fuel_Type;
  156.     string Horsepower;
  157. };
  158. car::car(string m, string mo, string ye, string ca, string HP, string pr, string ft)
  159. {
  160.     mark = m;
  161.     model = mo;
  162.     yearbook = ye;
  163.     capacity = ca;
  164.     price = pr;
  165.     Fuel_Type = ft;
  166.     Horsepower = HP;
  167. }
  168. void car::printToStdout()
  169. {
  170.     cout << "The car brand: " << mark << endl;
  171.     cout << "Car model: " << model << endl;
  172.     cout << "Car capacity: " << capacity << endl;
  173.     cout << "Number of horsepower: " << Horsepower << endl;
  174.     cout <<"Car's production date: " << yearbook << endl;
  175.     cout << "Fuel type is: " << Fuel_Type << endl;
  176.     cout <<"The price is: " << price << " zlotych" << endl;
  177.     EnoughMoney();
  178. }
  179. void ChooseAcarMenu()
  180. {
  181.     int answer;
  182.     cout << "[1]Opel" << endl;
  183.     cout << "[2]Ford" << endl;
  184.     cout << "[3]Audi" << endl;
  185.     cout << "[4]BMW" << endl;
  186.     cout << "[5]Mercedes-Benz" << endl;
  187.     cin >> answer;
  188.     switch (answer)
  189.     {
  190.     case 1:
  191.     {
  192.         car
  193.             opel("Opel", "Insignia", "2019", "1.9", "150", "185 000", "Benzine");
  194.         opel.printToStdout();
  195.         break;
  196.     }
  197.     case 2:
  198.     {
  199.         car
  200.             ford("Ford", "Mustang", "2020", "5.2", "760", "800 000", "Benzine");
  201.         ford.printToStdout();
  202.         break;
  203.     }
  204.     case 3:
  205.     {
  206.         car
  207.             audi("Audi", "RS7", "2018", "4.9", "620", "400 000", "Benzine");
  208.         audi.printToStdout();
  209.         break;
  210.     }
  211.     case 4:
  212.     {
  213.         car
  214.             BMW("BMW", "M5", "2019", "4.4", "600", "627 303", "Benzine");
  215.         BMW.printToStdout();
  216.         break;
  217.     }
  218.     case 5:
  219.     {
  220.         car
  221.             mercedes("Mercedes-Benz", "CLS", "2019", "2.0", "245", "325 000", "Diesel");
  222.         mercedes.printToStdout();
  223.         break;
  224.     }
  225.     }
  226.  
  227. }
  228. int main()
  229. {
  230.     string answ = "Yes";
  231.     cout << "Hello !" << endl;
  232.     cout << "Do you want buy new car?(Yes/No)" << endl;
  233.     cin >> answ;
  234.     if (answ != "Yes")
  235.     {
  236.         cout << "go out";
  237.     }
  238.     else
  239.     {
  240.         system("cls");
  241.         cout << "Cars available for sale: " << endl;
  242.         ChooseAcarMenu();
  243.     }
  244. }
  245.