Guest User

Untitled

a guest
Sep 26th, 2018
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.53 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int deposit(int x, int y)
  7. {
  8. int newbal = x + y;
  9. return newbal;
  10. }
  11.  
  12. int withdraw(int x, int y)
  13. {
  14. int newbal = x - y;
  15. return newbal;
  16. }
  17. int main()
  18. {
  19. int menu;
  20. int selection;
  21. double x = 1000, y;
  22. int trans;
  23. char user[20], pass[20], pktc[3];
  24. string newuser, newpass;
  25.  
  26. do{
  27. system ("CLS");
  28. cout << "Welcome To Bank" << endl;
  29. cout << "[1] Register" << endl;
  30. cout << "[2] Login" << endl;
  31. cout << "[3] Exit" << endl;
  32. cout << "nnEnter command: " <<endl;
  33. cin >> menu;
  34. switch(menu)
  35. {
  36.  
  37. //----------------------------------------------------------------CASE 1------------------------------------------------------------------------------//
  38. //----------------------------------------------------------------REGISTER----------------------------------------------------------------------------//
  39.  
  40. case 1:
  41. system ("CLS");
  42. cout << "<-------REGISTER------->nn";
  43. cout << "Enter Name: ";
  44. cin >> user;
  45. newuser = user;
  46. cout << "Enter Password: ";
  47. cin >> pass;
  48. newpass = pass;
  49. cout <<"REGISTERED SUCCESSFULLY!" << endl;
  50. cout <<"nnPress Any key to contniue" << endl;
  51. cin >> pktc;
  52. system ("CLS");
  53.  
  54. break;
  55.  
  56. //------------------------------------------------------------END OF REGISTER--------------------------------------------------------------------------//
  57.  
  58.  
  59.  
  60. //----------------------------------------------------------------CASE 2------------------------------------------------------------------------------//
  61. //-----------------------------------------------------------------LOGIN------------------------------------------------------------------------------//
  62.  
  63. case 2:
  64. system ("CLS");
  65. cout << "<-------LOGIN------->nn";
  66. cout << "Enter Username: ";
  67. cin >> newuser;
  68. cout << "Enter Password: ";
  69. cin >> newpass;
  70. if(newuser != user || newpass != pass)
  71. {
  72.  
  73. //-------------------------------------------------------------FAILED LOGIN----------------------------------------------------------------------------//
  74.  
  75. cout << "nInvalid account" << endl;
  76. cout <<"nnPress Any key to contniue" << endl;
  77. cin >> pktc;
  78. system ("CLS");
  79. }
  80. else if (newuser == user || newpass == pass)
  81. {
  82.  
  83. //----------------------------------------------------------------CASE 2.1------------------------------------------------------------------------------//
  84. //------------------------------------------------------------SUCCESFULL LOGIN--------------------------------------------------------------------------//
  85.  
  86. system ("CLS");
  87. cout << "nn<-------------------------------WELCOME------------------------------->nn" << endl;
  88. cout<<"nWelcome To Banco De Nelio";
  89. cout<<"nUSERNAME: "<< user << endl;
  90. cout<<"nn TIP ATM MACHINE";
  91. cout<<"n 1. Balance";
  92. cout<<"n 2. Deposit";
  93. cout<<"n 3. Withdraw";
  94. cout<<"n 4. Exit";
  95.  
  96. do{
  97.  
  98. cout<<"nnChoose Transaction[1-3]:";
  99. cin>>trans;
  100.  
  101. switch(trans)
  102. {
  103.  
  104. //----------------------------------------------------------------ATM CASE 1------------------------------------------------------------------------------//
  105. //--------------------------------------------------------------CHECK BALANCE--------------------------------------------------------------------------//
  106.  
  107. case 1:
  108. system ("CLS");
  109. cout << "nn<-------------------------------WELCOME------------------------------->nn" << endl;
  110. cout<<"nWelcome To Banco De Nelio";
  111. cout<<"nUSERNAME: "<< user << endl;
  112. cout<<"nn TIP ATM MACHINE";
  113. cout<<"n 1. Balance";
  114. cout<<"n 2. Deposit";
  115. cout<<"n 3. Withdraw";
  116. cout<<"n 4. Exit";
  117. cout<<"nnYour total balance is: "<< deposit(x, y) ;
  118. break;
  119.  
  120. //----------------------------------------------------------------ATM CASE 2------------------------------------------------------------------------------//
  121. //--------------------------------------------------------------BEFORE DEPOSIT--------------------------------------------------------------------------//
  122.  
  123. case 2:
  124. system ("CLS");
  125. cout << "nn<-------------------------------WELCOME------------------------------->nn" << endl;
  126. cout<<"nWelcome To Banco De Nelio";
  127. cout<<"nUSERNAME: "<< user << endl;
  128. cout<<"nn TIP ATM MACHINE";
  129. cout<<"n 1. Balance";
  130. cout<<"n 2. Deposit";
  131. cout<<"n 3. Withdraw";
  132. cout<<"n 4. Exit";
  133. cout<<"nnEnter the amount:" ;
  134. cin>>y;
  135.  
  136. //--------------------------------------------------------------AFTER DEPOSIT--------------------------------------------------------------------------//
  137.  
  138. system ("CLS");
  139. cout << "nn<-------------------------------WELCOME------------------------------->nn" << endl;
  140. cout<<"nWelcome To Banco De Nelio";
  141. cout<<"nUSERNAME: "<< user << endl;
  142. cout<<"nn TIP ATM MACHINE";
  143. cout<<"n 1. Balance";
  144. cout<<"n 2. Deposit";
  145. cout<<"n 3. Withdraw";
  146. cout<<"n 4. Exit";
  147. cout<<"nnYour total balance now is: " << deposit(x, y) <<endl;
  148. break;
  149.  
  150. //----------------------------------------------------------------ATM CASE 3------------------------------------------------------------------------------//
  151. //--------------------------------------------------------------WITHDRAW BALANCE--------------------------------------------------------------------------//
  152.  
  153. case 3:
  154. cout<<"nEnter the amount:" ;
  155. cin>>y;
  156. if ( y > x)
  157. {
  158. cout<<"nYou cannot withdraw " << y;
  159. cout<<" because the amount is higher than your balance" << endl;
  160. break;
  161. }
  162. else
  163. x = x - y;
  164. cout<<"nYour Total Balance is now " << withdraw(x, y) << endl;
  165. break;
  166.  
  167. //----------------------------------------------------------------ATM CASE 4------------------------------------------------------------------------------//
  168. //-------------------------------------------------------------------BACK--------------------------------------------------------------------------------//
  169.  
  170. case 4:
  171. cout<<"nnThank You!" << endl;
  172. break;
  173. default:
  174. cout<<"nYou did not enter any valid number" << endl;
  175. break;
  176. }
  177. }while (trans<=3);
  178. }
  179. break;
  180.  
  181. //----------------------------------------------------------------CASE 3------------------------------------------------------------------------------//
  182. //-----------------------------------------------------------------EXIT-------------------------------------------------------------------------------//
  183.  
  184. case 3:
  185. system ("CLS");
  186. cout << "Thank you for using me!n";
  187. return 0;
  188. //-------------------------------------------------------------END OF EXIT----------------------------------------------------------------------------//
  189. }
  190.  
  191. }while (menu<=3);
  192. }
  193.  
  194. int add(int x,int y) { return a+b; }
  195. int sub(int x,int y) { return a-b; }
  196.  
  197. int main() {
  198. int initial = 0;
  199. // add 10 then subtract 5
  200. std::cout << add(initial,10) << 'n'; // prints 10
  201. std::cout << sub(initial,5) << 'n'; // prints -5
  202. }
  203.  
  204. int main() {
  205. int initial = 0;
  206. // add 10 then subtract 5 and update initial
  207. initial = add(initial,10);
  208. std::cout << initial << 'n';
  209. initial = sub(initial,5);
  210. std::cout << initial << 'n';
  211. }
Add Comment
Please, Sign In to add comment