Advertisement
Guest User

Untitled

a guest
Apr 1st, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 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[1000];
  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. else {
  33. cout << "Login fail" << endl;
  34. LoggedIn = false;
  35. }
  36. }
  37.  
  38.  
  39. while (LoggedIn) {
  40. int choice, amount = 0, balance2 = 0;
  41. menu();
  42. cin >> choice;
  43. //elly by3d el lines
  44. int num_of_lines = 0;
  45. string lines;
  46. ifstream web(c.username + "proccess.txt");
  47. while (!web.eof()) {
  48. web >> lines;
  49. ++num_of_lines;
  50. }
  51. if (choice == 1)
  52. {
  53. cout << "Enter Amount of money to Deposit\n";
  54. cin >> amount;
  55. ifstream in(c.username + ".txt");
  56. in >> un >> pw >> balance2;
  57. c.Balance = balance2 + amount;
  58. ofstream out;
  59. out.open(c.username + ".txt");
  60. out << c.username << endl << c.password << endl << c.Balance << endl;
  61. out.close();
  62. std::ofstream data(c.username + "proccess.txt", std::ios_base::app | std::ios_base::out);
  63. data << "Deposite:" << amount << endl;
  64. }
  65. if (choice == 2)
  66. {
  67. cout << "Enter Amount of money to Withdraw\n";
  68. cin >> amount;
  69.  
  70. ifstream in(c.username + ".txt");
  71. in >> un >> pw >> balance2;
  72. if (amount <= balance2) {
  73. c.Balance = balance2 - amount;
  74. ofstream out;
  75. out.open(c.username + ".txt");
  76. out << c.username << endl << c.password << endl << c.Balance << endl;
  77. out.close();
  78. std::ofstream data(c.username + "proccess.txt", std::ios_base::app | std::ios_base::out);
  79. data << "Withdraw:" << amount << endl;
  80. }
  81. else {
  82. cout << "Your Balance isn't enough for this proccess\n";
  83. }
  84. }
  85. if (choice == 3)
  86. {
  87. ifstream in(c.username + ".txt");
  88. in >> un >> pw >> balance2;
  89. cout << "Your current balance is : " << balance2 << endl;
  90. }
  91. if (choice == 4)
  92. {
  93. num_of_lines = num_of_lines - 1;
  94. ifstream in(c.username + "proccess.txt");
  95.  
  96. //cout << num_of_lines;
  97. int cont = 0;
  98. for (int i = 0; i < num_of_lines; i++) {
  99. in >> arr[i].x;
  100. }
  101.  
  102. in.close();
  103.  
  104. for (int i = num_of_lines; i > 0; i--) {
  105. cout << arr[i].x << endl;
  106. cont++;
  107. if (cont > 5) { break;
  108. }
  109. }
  110. }
  111. if (choice == 5)
  112. {
  113. LoggedIn = false;
  114. break;
  115. }
  116. }
  117. return 0;
  118. }
  119. void menu() {
  120. cout << "Please choose what do you want to do\n";
  121. cout << "1/Deposit\n2/Withdraw\n3/Inquiry about your Balance\n4/Last 5 procedures\n5/Exit\n";
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement