Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- struct Customer
- {
- string username, password;
- double Balance;
- }c;
- struct Last
- {
- string x;
- }L;
- void menu();
- int main()
- {
- Last arr[1000];
- cout << "=======================================\n";
- cout << "==Welcome to Automatic Teller Machine==\n";
- cout << "==Please Enter your Username/Password==\n";
- string un, pw;
- bool LoggedIn = true;
- cout << "Enter Username :";
- cin >> c.username;
- cout << "Enter Password :";
- cin >> c.password;
- ifstream in(c.username + ".txt");
- while (in >> un >> pw) {
- if (un == c.username && pw == c.password) {
- cout << "successfuly logged in" << endl;
- }
- else {
- cout << "Login fail" << endl;
- LoggedIn = false;
- }
- }
- while (LoggedIn) {
- int choice, amount = 0, balance2 = 0;
- menu();
- cin >> choice;
- //elly by3d el lines
- int num_of_lines = 0;
- string lines;
- ifstream web(c.username + "proccess.txt");
- while (!web.eof()) {
- web >> lines;
- ++num_of_lines;
- }
- if (choice == 1)
- {
- cout << "Enter Amount of money to Deposit\n";
- cin >> amount;
- ifstream in(c.username + ".txt");
- in >> un >> pw >> balance2;
- c.Balance = balance2 + amount;
- ofstream out;
- out.open(c.username + ".txt");
- out << c.username << endl << c.password << endl << c.Balance << endl;
- out.close();
- std::ofstream data(c.username + "proccess.txt", std::ios_base::app | std::ios_base::out);
- data << "Deposite:" << amount << endl;
- }
- if (choice == 2)
- {
- cout << "Enter Amount of money to Withdraw\n";
- cin >> amount;
- ifstream in(c.username + ".txt");
- in >> un >> pw >> balance2;
- if (amount <= balance2) {
- c.Balance = balance2 - amount;
- ofstream out;
- out.open(c.username + ".txt");
- out << c.username << endl << c.password << endl << c.Balance << endl;
- out.close();
- std::ofstream data(c.username + "proccess.txt", std::ios_base::app | std::ios_base::out);
- data << "Withdraw:" << amount << endl;
- }
- else {
- cout << "Your Balance isn't enough for this proccess\n";
- }
- }
- if (choice == 3)
- {
- ifstream in(c.username + ".txt");
- in >> un >> pw >> balance2;
- cout << "Your current balance is : " << balance2 << endl;
- }
- if (choice == 4)
- {
- num_of_lines = num_of_lines - 1;
- ifstream in(c.username + "proccess.txt");
- //cout << num_of_lines;
- int cont = 0;
- for (int i = 0; i < num_of_lines; i++) {
- in >> arr[i].x;
- }
- in.close();
- for (int i = num_of_lines; i > 0; i--) {
- cout << arr[i].x << endl;
- cont++;
- if (cont > 5) { break;
- }
- }
- }
- if (choice == 5)
- {
- LoggedIn = false;
- break;
- }
- }
- return 0;
- }
- void menu() {
- cout << "Please choose what do you want to do\n";
- cout << "1/Deposit\n2/Withdraw\n3/Inquiry about your Balance\n4/Last 5 procedures\n5/Exit\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement