Advertisement
Guest User

Untitled

a guest
Mar 31st, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.53 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. using namespace std;
  5. struct Customer
  6. {
  7.     string username, password;
  8.     double Balance;
  9. }c;
  10. struct Last
  11. {
  12.     string x;
  13. }L;
  14. void menu();
  15. int main()
  16. {
  17.     Last arr[5];
  18.     cout << "=======================================\n";
  19.     cout << "==Welcome to Automatic Teller Machine==\n";
  20.     cout << "==Please Enter your Username/Password==\n";
  21.     string un, pw;
  22.     bool LoggedIn = true;
  23.     cout << "Enter Username :";
  24.     cin >> c.username;
  25.     cout << "Enter Password :";
  26.     cin >> c.password;
  27.     ifstream in(c.username + ".txt");
  28.     while (in >> un >> pw){
  29.         if (un == c.username && pw == c.password){
  30.             cout << "successfuly logged in" << endl;
  31.  
  32.         }
  33.         else {
  34.             cout << "Login fail" << endl;
  35.             LoggedIn = false;
  36.         }
  37.     }
  38.     while (LoggedIn){
  39.         int choice, amount = 0, balance2 = 0;
  40.         menu();
  41.         cin >> choice;
  42.         if (choice == 1)
  43.         {
  44.             cout << "Enter Amount of money to Deposit\n";
  45.             cin >> amount;
  46.             ifstream in(c.username + ".txt");
  47.             in >> un >> pw >> balance2;
  48.             c.Balance = balance2 + amount;
  49.             ofstream out;
  50.             out.open(c.username + ".txt");
  51.             out << c.username << endl << c.password << endl << c.Balance << endl;
  52.             out.close();
  53.             std::ofstream data(c.username + "proccess.txt", std::ios_base::app | std::ios_base::out);
  54.             data << "Deposite:" << amount << endl;
  55.         }
  56.         if (choice == 2)
  57.         {
  58.             cout << "Enter Amount of money to Withdraw\n";
  59.             cin >> amount;
  60.  
  61.             ifstream in(c.username + ".txt");
  62.             in >> un >> pw >> balance2;
  63.             if (amount <= balance2) {
  64.                 c.Balance = balance2 - amount;
  65.                 ofstream out;
  66.                 out.open(c.username + ".txt");
  67.                 out << c.username << endl << c.password << endl << c.Balance << endl;
  68.                 out.close();
  69.                 std::ofstream data(c.username + "proccess.txt", std::ios_base::app | std::ios_base::out);
  70.                 data << "Withdraw:" << amount << endl;
  71.             }
  72.             else {
  73.                 cout << "Your Balance isn't enough for this proccess\n";
  74.             }
  75.         }
  76.         if (choice == 3)
  77.         {
  78.             ifstream in(c.username + ".txt");
  79.             in >> un >> pw >> balance2;
  80.             cout << "Your current balance is : " << balance2 << endl;
  81.         }
  82.         if (choice == 4)
  83.         {
  84.             ifstream in(c.username + "proccess.txt");
  85.             for (int i = 0; i < 5; i++){
  86.                 in >> arr[i].x;
  87.             }
  88.             in.close();
  89.             for (int i = 0; i < 5; i++){
  90.                 cout << arr[i].x << endl;
  91.             }
  92.         }
  93.  
  94.         if (choice == 5)
  95.         {
  96.             LoggedIn = false;
  97.             break;
  98.         }
  99.     }
  100.     return 0;
  101. }
  102. void menu(){
  103.     cout << "Please choose what do you want to do\n";
  104.     cout << "1/Deposit\n2/Withdraw\n3/Inquiry about your Balance\n4/Last 5 procedures\n5/Exit\n";
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement