Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows.h>
  3. #include <fstream>
  4. #include <string>
  5.  
  6.  
  7. using namespace std;
  8.  
  9. void title();
  10. string username,password;
  11. string Username=username;
  12. string Password=password;
  13. void login()
  14. {
  15. string username,password;
  16. string newusername, newpassword;
  17. char respond;
  18. cout << "Do you have an account? Y/Nn";
  19. cin >> respond;
  20. if (respond == 'Y'|| respond == 'y'){
  21.  
  22. ifstream inFile;
  23. inFile.open("newuser.txt");
  24.  
  25. if (inFile.fail()){
  26. cerr << "Error! x_xnPlease reopen this program." << endl;
  27. system("PAUSE");
  28. exit(1);
  29. }
  30.  
  31. cout << "Please enter your username: ";
  32. cin >> username;
  33. cout << "nPlease enter your password: ";
  34. cin >> password;
  35.  
  36. string vusername,vpassword;
  37. while(!inFile.eof()){
  38. inFile >> vusername >> vpassword;
  39. if (vusername==username && vpassword==password){
  40. cout << "Login Successfully!" << endl;
  41. }else{
  42. cout << "Fail to login...Please reopen this program." << endl;
  43. system("PAUSE");
  44. exit(1);
  45. }
  46. }
  47. }
  48. else if (respond == 'N'|| respond == 'n'){
  49. cout << "Please enter your desired username:";
  50. cin >> newusername;
  51. cout << "nPlease enter your desired password:";
  52. cin >> newpassword;
  53.  
  54. ofstream outFile;
  55. outFile.open("newuser.txt");
  56. outFile << newusername << " " << newpassword << endl;
  57. outFile.close();
  58. cout << "n******************************************";
  59. cout << "nnPlease enter your username: ";
  60. cin >> username;
  61. cout << "nPlease enter your password: ";
  62. cin >> password;
  63.  
  64. ifstream inFile;
  65. inFile.open("newuser.txt");
  66.  
  67. if (inFile.fail()){
  68. cerr << "Error! x_xnPlease reopen this program." << endl;
  69. system("PAUSE");
  70. exit(1);
  71. }
  72. string vusername1,vpassword1;
  73. while(!inFile.eof()){
  74. inFile >> vusername1 >> vpassword1;
  75. if (vusername1==username && vpassword1==password){
  76. cout << "Login Successfully!" << endl;
  77.  
  78. username += ".txt";
  79. ofstream createFile;
  80. createFile.open(username.c_str(),ios::app);
  81. createFile << username << "n" << "Balance: n";
  82. }else{
  83. cout << "Fail to login...Please reopen this program." << endl;
  84. system("PAUSE");
  85. exit(1);
  86. }
  87. }
  88. }
  89.  
  90. }
  91.  
  92. void title()
  93. {
  94. cout << "This is a bank system. Enjoy! :)" << endl;
  95. cout << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^nnn";
  96. cout << " _________________________________________n";
  97. cout << " | WELCOME TO YOUR PERSONAL BANK ACCOUNT!|" << endl;
  98. cout << " |_____________________________________|nnn";
  99. }
  100.  
  101. void functions()
  102. {
  103. int choice;
  104. cout << " ***************************" << endl;
  105. cout << " 1. Account Information" << endl;
  106. cout << " 2. Manage Your Money" << endl;
  107. cout << " 3. Investments" << endl;
  108. cout << " 4. Loans" << endl;
  109. cout << " 5. Delete Account" << endl;
  110. cout << " ***************************" << endl;
  111. cout << " Please enter your choice: ";
  112. cin >> choice;
  113.  
  114. switch(choice)
  115. {
  116. case 1:
  117. ifstream inFile;
  118. string name;
  119. cout << "Please enter your username: ";
  120. // getline(cin,name);
  121. //name += ".txt";
  122. //inFile.open(name.c_str());
  123.  
  124. while(getline(cin,name)){
  125. name += ".txt";
  126. inFile.open(name.c_str());
  127. }
  128.  
  129. if(inFile.fail()){
  130. cerr << "Error Opening File" << endl;
  131. system("PAUSE");
  132. exit(1);
  133. }
  134. string info;
  135. int line = 0;
  136.  
  137. while(!inFile.eof()){
  138. inFile >> info;
  139. line++;
  140. }
  141.  
  142. break;
  143.  
  144. }
  145. }
  146.  
  147. int main()
  148. {
  149. login();
  150. title();
  151. functions();
  152. system("PAUSE");
  153. return 0;
  154. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement