Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Bank {
- public static void main(String[] args) {
- int option1;
- Scanner sc = new Scanner(System.in);
- while(true)
- {
- System.out.println("Enter 1 for SavingsAccount");
- System.out.println("Enter 2 for CurrentAccount");
- System.out.println("Enter 3 for StudentAccount");
- System.out.println("Enter 0 to exit");
- option1=sc.nextInt();
- if(option1==1)
- {
- String name;
- System.out.println("Enter Name: ");
- name = sc.next();
- double accountBalance;
- System.out.println("Enter account balance");
- accountBalance = sc.nextDouble();
- SavingsAccount sa = new SavingsAccount(name, accountBalance);
- System.out.println("Enter maximum withdraw limit");
- sa.maxWithLimit=sc.nextDouble();
- while(true)
- {
- String option2;
- System.out.println("Enter 1 or d to deposit money");
- System.out.println("Enter 2 to withdraw money");
- System.out.println("Enter 3 to display");
- System.out.println("Enter 0 to exit");
- option2=sc.nextLine();
- if(option2=="1"||option2=="d")
- {
- System.out.println("Enter balance you want to deposit");
- double balance = sc.nextDouble();
- sa.deposit(balance);
- }
- if(option2=="2")
- {
- System.out.println("Enter the amount you want to withdraw");
- double balance=sc.nextDouble();
- sa.withdraw(balance);
- }
- if(option2=="3")
- {
- double balance = sa.getBalance();
- System.out.println(balance);
- }
- if(option2=="0")
- {
- break;
- }
- }
- }
- if(option1==2)
- {
- String name;
- System.out.println("Enter Name: ");
- name = sc.next();
- double accountBalance;
- System.out.println("Enter account balance");
- accountBalance = sc.nextDouble();
- System.out.println("Enter trade license number");
- int tradeLicenseNumber = sc.nextInt();
- CurrentAccount ca = new CurrentAccount(name, accountBalance, tradeLicenseNumber);
- while(true)
- {
- String option2;
- System.out.println("Enter 1 or d to deposit money");
- System.out.println("Enter 2 to withdraw money");
- System.out.println("Enter 3 to display");
- System.out.println("Enter 0 to exit");
- option2=sc.nextLine();
- if(option2=="1"||option2=="d")
- {
- System.out.println("Enter balance you want to deposit");
- double balance = sc.nextDouble();
- ca.deposit(balance);
- }
- if(option2=="2")
- {
- System.out.println("Enter the amount you want to withdraw");
- double balance=sc.nextDouble();
- ca.withdraw(balance);
- }
- if(option2=="3")
- {
- double balance = ca.getBalance();
- System.out.println(balance);
- }
- if(option2=="0")
- {
- break;
- }
- }
- }
- if(option1==3)
- {
- String name,institutionName;
- System.out.println("Enter Name: ");
- name = sc.next();
- double accountBalance;
- System.out.println("Enter account balance");
- accountBalance = sc.nextDouble();
- System.out.println("Enter institution name: ");
- institutionName = sc.next();
- StudentAccount sta = new StudentAccount(name, accountBalance,institutionName);
- while(true)
- {
- String option2;
- System.out.println("Enter 1 or d to deposit money");
- System.out.println("Enter 2 to withdraw money");
- System.out.println("Enter 3 to display");
- System.out.println("Enter 0 to exit");
- option2=sc.nextLine();
- if(option2=="1"||option2=="d")
- {
- System.out.println("Enter balance you want to deposit");
- double balance = sc.nextDouble();
- sta.deposit(balance);
- }
- if(option2=="2")
- {
- System.out.println("Enter the amount you want to withdraw");
- double balance=sc.nextDouble();
- sta.withdraw(balance);
- }
- if(option2=="3")
- {
- double balance = sta.getBalance();
- System.out.println(balance);
- }
- if(option2=="0")
- {
- break;
- }
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment