ruhul0

Bank

Mar 6th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.06 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Bank {
  4.  
  5.     public static void main(String[] args) {
  6.         int option1;
  7.         Scanner sc = new Scanner(System.in);
  8.         while(true)
  9.         {
  10.             System.out.println("Enter 1 for SavingsAccount");
  11.             System.out.println("Enter 2 for CurrentAccount");
  12.             System.out.println("Enter 3 for StudentAccount");
  13.             System.out.println("Enter 0 to exit");
  14.             option1=sc.nextInt();
  15.             if(option1==1)
  16.             {
  17.                 String name;
  18.                 System.out.println("Enter Name: ");
  19.                 name = sc.next();
  20.                 double accountBalance;
  21.                 System.out.println("Enter account balance");
  22.                 accountBalance = sc.nextDouble();
  23.                 SavingsAccount sa = new SavingsAccount(name, accountBalance);
  24.                 System.out.println("Enter maximum withdraw limit");
  25.                 sa.maxWithLimit=sc.nextDouble();
  26.                 while(true)
  27.                 {
  28.                     String option2;
  29.                     System.out.println("Enter 1 or d to deposit money");
  30.                     System.out.println("Enter 2 to withdraw money");
  31.                     System.out.println("Enter 3 to display");
  32.                     System.out.println("Enter 0 to exit");
  33.                     option2=sc.nextLine();
  34.                     if(option2=="1"||option2=="d")
  35.                     {
  36.                         System.out.println("Enter balance you want to deposit");
  37.                         double balance = sc.nextDouble();
  38.                         sa.deposit(balance);
  39.                     }
  40.                     if(option2=="2")
  41.                     {
  42.                         System.out.println("Enter the amount you want to withdraw");
  43.                         double balance=sc.nextDouble();
  44.                         sa.withdraw(balance);
  45.                        
  46.                     }
  47.                     if(option2=="3")
  48.                     {
  49.                         double balance = sa.getBalance();
  50.                         System.out.println(balance);
  51.                     }
  52.                     if(option2=="0")
  53.                     {
  54.                         break;
  55.                     }
  56.                 }
  57.                
  58.             }
  59.             if(option1==2)
  60.             {
  61.                 String name;
  62.                 System.out.println("Enter Name: ");
  63.                 name = sc.next();
  64.                 double accountBalance;
  65.                 System.out.println("Enter account balance");
  66.                 accountBalance = sc.nextDouble();
  67.                 System.out.println("Enter trade license number");
  68.                 int tradeLicenseNumber = sc.nextInt();
  69.                 CurrentAccount ca = new CurrentAccount(name, accountBalance, tradeLicenseNumber);
  70.                 while(true)
  71.                 {
  72.                     String option2;
  73.                     System.out.println("Enter 1 or d to deposit money");
  74.                     System.out.println("Enter 2 to withdraw money");
  75.                     System.out.println("Enter 3 to display");
  76.                     System.out.println("Enter 0 to exit");
  77.                     option2=sc.nextLine();
  78.                     if(option2=="1"||option2=="d")
  79.                     {
  80.                         System.out.println("Enter balance you want to deposit");
  81.                         double balance = sc.nextDouble();
  82.                         ca.deposit(balance);
  83.                     }
  84.                     if(option2=="2")
  85.                     {
  86.                         System.out.println("Enter the amount you want to withdraw");
  87.                         double balance=sc.nextDouble();
  88.                         ca.withdraw(balance);
  89.                        
  90.                     }
  91.                     if(option2=="3")
  92.                     {
  93.                         double balance = ca.getBalance();
  94.                         System.out.println(balance);
  95.                     }
  96.                     if(option2=="0")
  97.                     {
  98.                         break;
  99.                     }
  100.                 }
  101.                
  102.             }
  103.             if(option1==3)
  104.             {
  105.                 String name,institutionName;
  106.                 System.out.println("Enter Name: ");
  107.                 name = sc.next();
  108.                 double accountBalance;
  109.                 System.out.println("Enter account balance");
  110.                 accountBalance = sc.nextDouble();
  111.                 System.out.println("Enter institution name: ");
  112.                 institutionName = sc.next();
  113.                 StudentAccount sta = new StudentAccount(name, accountBalance,institutionName);
  114.                
  115.                 while(true)
  116.                 {
  117.                     String option2;
  118.                     System.out.println("Enter 1 or d to deposit money");
  119.                     System.out.println("Enter 2 to withdraw money");
  120.                     System.out.println("Enter 3 to display");
  121.                     System.out.println("Enter 0 to exit");
  122.                     option2=sc.nextLine();
  123.                     if(option2=="1"||option2=="d")
  124.                     {
  125.                         System.out.println("Enter balance you want to deposit");
  126.                         double balance = sc.nextDouble();
  127.                         sta.deposit(balance);
  128.                     }
  129.                     if(option2=="2")
  130.                     {
  131.                         System.out.println("Enter the amount you want to withdraw");
  132.                         double balance=sc.nextDouble();
  133.                         sta.withdraw(balance);
  134.                        
  135.                     }
  136.                     if(option2=="3")
  137.                     {
  138.                         double balance = sta.getBalance();
  139.                         System.out.println(balance);
  140.                     }
  141.                     if(option2=="0")
  142.                     {
  143.                         break;
  144.                     }
  145.                 }
  146.                
  147.             }
  148.            
  149.         }
  150.        
  151.  
  152.     }
  153.  
  154. }
Add Comment
Please, Sign In to add comment