Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Daniel Clements
- import java.util.*;
- public class Bank
- {
- public static void main(String args[])
- {
- System.out.print("Please enter your username: ");
- Scanner console = new Scanner(System.in);
- String user = console.next();
- int count = 0;
- String password = "";
- do{
- System.out.print("Please enter your password (must be atleast 8 characters: ");
- password = console.next();
- count = password.length();
- if (count < 8)
- {
- System.out.println("Please enter a longer password");
- }
- }while (count<8);
- double savings = 5000;
- double checking = 1000;
- for (int i = 4; i>0 ; i--)
- {
- System.out.println("How may we assist you? \n1. Deposit \n2. Withdrawl \n3. Summary Statement \n4. Exit");
- int choice = console.nextInt();
- System.out.println("**Your session has " + i + " actions remaining**");
- switch (choice)
- {
- case 1:
- System.out.println("How much would you like to deposit?");
- double amount = console.nextDouble();
- System.out.println("In which account? \n1. Checking \n2. Savings");
- int choice2 = console.nextInt();
- if (choice2 == 1)
- {
- checking += amount;
- System.out.println("Thank you, you now have $" + checking + " in your checking account!");
- }
- else
- {
- savings += amount;
- System.out.println("Thank you, you now have $" + savings + " in your savings account!");
- }
- break;
- case 2:
- System.out.println("How much would you like to withdraw?");
- double withdraw = console.nextDouble();
- System.out.println("From which account? \n1. Checking \n2. Savings");
- int choice3 = console.nextInt();
- if (choice3 == 1)
- {
- checking -= withdraw;
- System.out.println("Thank you, you now have $" + checking + " in your checking account!");
- }
- else
- {
- savings -= withdraw;
- System.out.println("Thank you, you now have $" + savings + " in your savings account!");
- }
- break;
- case 3:
- System.out.println("Summary Statement");
- System.out.println("Username: " + user);
- System.out.println("Password: " + password.substring(0, password.length() - 4) + "****");
- System.out.println("Savings: " + savings);
- System.out.println("Checking: " + checking);
- break;
- case 4:
- System.out.println("Thank You for Choosing Weston International Bank");
- System.out.println("Have a nice day!");
- System.exit(0);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement