Guest User

Untitled

a guest
Dec 2nd, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.25 KB | None | 0 0
  1. 1. asks user to input username and password(if user gets username and password wrong, the system will ask the user to try again. If the user gets the username and/or password wrong 3 times, the system closes.)(If user gets username/password correct, output a welcome area asking user to select option 1-5.(1. view balances, 2.deposit(money into other accounts in the bank[I need help/suggestion for that], 3.withdraw[from account], 4.transfer[to other accounts], 5. log off)
  2.  
  3. 2. If user enters correct bank information, output the options 1-5 above(user types in number to choose)
  4.  
  5. 3. give information/do actions/log off
  6.  
  7. *Note*
  8.  
  9. The information is on two text files. login.txt has the account information(ln1 admin)(ln2 says pass)
  10.  
  11. accounts.txt has the checkings account(ln1 1000) and the savings account(ln2 1000).
  12.  
  13. - Arrays are needed in this program
  14.  
  15.  
  16. **IMPORTANT**
  17. - I need help on: responding to the user's input(1-5)
  18. - I need suggestions/corrections on: how to improve or what to fix/change.
  19.  
  20.  
  21. Hi,
  22. I am having difficulties with my code. I am supposed to create an atm machine that:
  23.  
  24. 1. asks user to input username and password(if user gets username and password wrong, the system will ask the user to try again. If the user gets the username and/or password wrong 3 times, the system closes.)(If user gets username/password correct, output a welcome area asking user to select option 1-5.(1. view balances, 2.deposit(money into other accounts in the bank[I need help/suggestion for that], 3.withdraw[from account], 4.transfer[to other accounts], 5. log off)
  25.  
  26. 2. If user enters correct bank information, output the options 1-5 above(user types in number to choose)
  27.  
  28. 3. give information/do actions/log off
  29.  
  30. *Note*
  31.  
  32. The information is on two text files. login.txt has the account information(ln1 admin)(ln2 says pass)
  33.  
  34. accounts.txt has the checkings account(ln1 1000) and the savings account(ln2 1000).
  35.  
  36. - Arrays are needed in this program
  37.  
  38.  
  39. **IMPORTANT**
  40. - I need help on: responding to the user's input(1-5)
  41. - I need suggestions/corrections on: how to improve or what to fix/change.
  42.  
  43. package Unit3Task;
  44.  
  45. import java.io.BufferedReader;
  46. import java.io.FileReader;
  47. import java.io.IOException;
  48. import java.util.Scanner;
  49.  
  50. /*
  51. * Author:Robbie Altshuler
  52. * Purpose:To simulate a real-world ATM-Machine
  53. * Date:
  54. */
  55. public class TheBank {
  56.  
  57. public static void main(String[] args) throws IOException {
  58. double money1 = 0;
  59. double money2 = 0;
  60. String[] username = { " ", " " };// the account information(pass/user)
  61. String[] account = { " ", " " };//the first "" is for the chequings account, second "" is for the savings account
  62. FileReader fr = new FileReader("login.txt");
  63. FileReader fr1 = new FileReader("accounts.txt");
  64. BufferedReader br = new BufferedReader(fr);
  65. br = new BufferedReader(fr);
  66.  
  67. String line;
  68. // double [] accounts = {0,0};//first 0 is for chequings, second 0 is
  69. // for savings
  70. int i = 0;
  71. while ((line = br.readLine()) != null) {// String line cannot be equal
  72. // to null
  73. username[i] = line;// stores file ...
  74. i++;
  75.  
  76. }
  77. br.close();
  78. fr.close();
  79.  
  80. Scanner input = new Scanner(System.in);
  81. System.out.println("Please enter your username and password: ");
  82. String user = input.nextLine();
  83. String pass = input.nextLine();
  84. int counter = 0;
  85. while (!user.equals(username[0]) && !user.equals(username[1])) {
  86. counter++;
  87. System.out.println("Invalid password or username, please try again.");
  88. user = input.nextLine();
  89. pass = input.nextLine();
  90. if (counter > 2) {
  91. System.out.println("Invalid password or username, bye!");
  92. System.exit(0);
  93. return;
  94. }
  95. }
  96. if (user.equals(username[0]) || user.equals(username[1])) {
  97. fr.close();
  98. br.close();
  99. fr = new FileReader("accounts.txt");
  100. br = new BufferedReader(fr);
  101. String money = br.readLine();
  102. money1 = Double.parseDouble(money); //checking money
  103. String mon = br.readLine();
  104. money2 = Double.parseDouble(mon); //savings money
  105.  
  106. System.out.println("welcome " + username[0]);
  107. int balances = 1;
  108. int deposit = 2;
  109. int withdraw = 3;
  110. int transfer = 4;
  111. int logoff = 5;
  112. println();
  113.  
  114. int [] list = {1, 2, 3, 4, 5};
  115.  
  116. System.out.println("------------------------");
  117. System.out.println("(1)View Balances");
  118. System.out.println("(2)Deposit");
  119. System.out.println("(3)Withdraw");
  120. System.out.println("(4)Transfer(between accounts)");// how much, what accounts, to/from?
  121. System.out.println("(5)Log off");
  122. println();
  123. System.out.println("------------------------");
  124. int choice = input.nextInt();
  125.  
  126. choice = 1;
  127. System.out.println(fr1);
  128.  
  129. }
  130.  
  131. }
  132.  
  133. private static void println() {
  134. // TODO Auto-generated method stub
  135.  
  136. }
  137. }
Add Comment
Please, Sign In to add comment