Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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. If user enters correct bank information, output the options 1-5 above(user types in number to choose)
- 3. give information/do actions/log off
- *Note*
- The information is on two text files. login.txt has the account information(ln1 admin)(ln2 says pass)
- accounts.txt has the checkings account(ln1 1000) and the savings account(ln2 1000).
- - Arrays are needed in this program
- **IMPORTANT**
- - I need help on: responding to the user's input(1-5)
- - I need suggestions/corrections on: how to improve or what to fix/change.
- Hi,
- I am having difficulties with my code. I am supposed to create an atm machine that:
- 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. If user enters correct bank information, output the options 1-5 above(user types in number to choose)
- 3. give information/do actions/log off
- *Note*
- The information is on two text files. login.txt has the account information(ln1 admin)(ln2 says pass)
- accounts.txt has the checkings account(ln1 1000) and the savings account(ln2 1000).
- - Arrays are needed in this program
- **IMPORTANT**
- - I need help on: responding to the user's input(1-5)
- - I need suggestions/corrections on: how to improve or what to fix/change.
- package Unit3Task;
- import java.io.BufferedReader;
- import java.io.FileReader;
- import java.io.IOException;
- import java.util.Scanner;
- /*
- * Author:Robbie Altshuler
- * Purpose:To simulate a real-world ATM-Machine
- * Date:
- */
- public class TheBank {
- public static void main(String[] args) throws IOException {
- double money1 = 0;
- double money2 = 0;
- String[] username = { " ", " " };// the account information(pass/user)
- String[] account = { " ", " " };//the first "" is for the chequings account, second "" is for the savings account
- FileReader fr = new FileReader("login.txt");
- FileReader fr1 = new FileReader("accounts.txt");
- BufferedReader br = new BufferedReader(fr);
- br = new BufferedReader(fr);
- String line;
- // double [] accounts = {0,0};//first 0 is for chequings, second 0 is
- // for savings
- int i = 0;
- while ((line = br.readLine()) != null) {// String line cannot be equal
- // to null
- username[i] = line;// stores file ...
- i++;
- }
- br.close();
- fr.close();
- Scanner input = new Scanner(System.in);
- System.out.println("Please enter your username and password: ");
- String user = input.nextLine();
- String pass = input.nextLine();
- int counter = 0;
- while (!user.equals(username[0]) && !user.equals(username[1])) {
- counter++;
- System.out.println("Invalid password or username, please try again.");
- user = input.nextLine();
- pass = input.nextLine();
- if (counter > 2) {
- System.out.println("Invalid password or username, bye!");
- System.exit(0);
- return;
- }
- }
- if (user.equals(username[0]) || user.equals(username[1])) {
- fr.close();
- br.close();
- fr = new FileReader("accounts.txt");
- br = new BufferedReader(fr);
- String money = br.readLine();
- money1 = Double.parseDouble(money); //checking money
- String mon = br.readLine();
- money2 = Double.parseDouble(mon); //savings money
- System.out.println("welcome " + username[0]);
- int balances = 1;
- int deposit = 2;
- int withdraw = 3;
- int transfer = 4;
- int logoff = 5;
- println();
- int [] list = {1, 2, 3, 4, 5};
- System.out.println("------------------------");
- System.out.println("(1)View Balances");
- System.out.println("(2)Deposit");
- System.out.println("(3)Withdraw");
- System.out.println("(4)Transfer(between accounts)");// how much, what accounts, to/from?
- System.out.println("(5)Log off");
- println();
- System.out.println("------------------------");
- int choice = input.nextInt();
- choice = 1;
- System.out.println(fr1);
- }
- }
- private static void println() {
- // TODO Auto-generated method stub
- }
- }
Add Comment
Please, Sign In to add comment