|
| 1 | +import java.text.DecimalFormat; |
| 2 | +import java.util.Scanner; |
| 3 | + |
| 4 | +public class Account { |
| 5 | + |
| 6 | + private int customerNumber; |
| 7 | + private int pinNumber; |
| 8 | + private double checkingBalance = 0; |
| 9 | + private double savingBalance = 0; |
| 10 | + |
| 11 | + Scanner input = new Scanner(System.in); |
| 12 | + DecimalFormat moneyFormat = new DecimalFormat("'$'###,##0.00"); |
| 13 | + |
| 14 | + public void setCustomerNumber(int customerNumber){ |
| 15 | + this.customerNumber = customerNumber; |
| 16 | + } |
| 17 | + |
| 18 | + public int getCustomerNumber(){ |
| 19 | + return customerNumber; |
| 20 | + } |
| 21 | + |
| 22 | + public void setPinNumber(int pinNumber){ |
| 23 | + this.pinNumber = pinNumber; |
| 24 | + } |
| 25 | + |
| 26 | + public int getPinNumber(){ |
| 27 | + return pinNumber; |
| 28 | + } |
| 29 | + |
| 30 | + public double getCheckingBalance() { |
| 31 | + return checkingBalance; |
| 32 | + } |
| 33 | + |
| 34 | + public double getSavingBalance(){ |
| 35 | + return savingBalance; |
| 36 | + } |
| 37 | + |
| 38 | + public void calcCheckingWithdraw(double amount){ |
| 39 | + checkingBalance = (checkingBalance - amount); |
| 40 | + } |
| 41 | + |
| 42 | + public void calcSavingWithdraw(double amount){ |
| 43 | + savingBalance = (savingBalance - amount); |
| 44 | + } |
| 45 | + |
| 46 | + public void calcCheckingDeposit(double amount){ |
| 47 | + checkingBalance = (checkingBalance + amount); |
| 48 | + } |
| 49 | + |
| 50 | + public void calcSavingDeposit(double amount){ |
| 51 | + savingBalance = (savingBalance + amount); |
| 52 | + } |
| 53 | + |
| 54 | + public void getCheckingWithdrawInput() { |
| 55 | + System.out.println("Checking Account balance: " + moneyFormat.format(checkingBalance)); |
| 56 | + System.out.print("Amount you want to withdraw from Checking Account: "); |
| 57 | + double amount = input.nextDouble(); |
| 58 | + |
| 59 | + if(checkingBalance - amount >= 0){ |
| 60 | + calcCheckingWithdraw(amount); |
| 61 | + System.out.println("New Checking Account Balance: " + moneyFormat.format(checkingBalance)); |
| 62 | + } |
| 63 | + else{ |
| 64 | + System.out.println("Not Enough Money to Withdraw"); |
| 65 | + } |
| 66 | + } |
| 67 | + |
| 68 | + public void getSavingWithdrawInput() { |
| 69 | + System.out.println("Saving Account balance: " + moneyFormat.format(savingBalance)); |
| 70 | + System.out.print("Amount you want to withdraw from Saving Account: "); |
| 71 | + double amount = input.nextDouble(); |
| 72 | + |
| 73 | + if(savingBalance - amount >= 0){ |
| 74 | + calcSavingWithdraw(amount); |
| 75 | + System.out.println("New Saving Account Balance: " + moneyFormat.format(savingBalance)); |
| 76 | + } |
| 77 | + else{ |
| 78 | + System.out.println("Not Enough Money to Withdraw"); |
| 79 | + } |
| 80 | + } |
| 81 | + |
| 82 | + public void getCheckingDepositInput(){ |
| 83 | + System.out.println("Checking Account Balance: " + moneyFormat.format(checkingBalance)); |
| 84 | + System.out.print("Amount you want to deposit to Checking Account: "); |
| 85 | + double amount = input.nextDouble(); |
| 86 | + |
| 87 | + if(checkingBalance + amount >= 0){ |
| 88 | + calcCheckingDeposit(amount); |
| 89 | + System.out.println("New Checking Account Balance: " + moneyFormat.format(checkingBalance)); |
| 90 | + } |
| 91 | + else{ |
| 92 | + System.out.println("No Money to Deposit"); |
| 93 | + } |
| 94 | + } |
| 95 | + |
| 96 | + public void getSavingDepositInput(){ |
| 97 | + System.out.println("Saving Account Balance: " + moneyFormat.format(savingBalance)); |
| 98 | + System.out.print("Amount you want to deposit to Saving Account: "); |
| 99 | + double amount = input.nextDouble(); |
| 100 | + |
| 101 | + if(checkingBalance + amount >= 0){ |
| 102 | + calcSavingDeposit(amount); |
| 103 | + System.out.println("New Saving Account Balance: " + moneyFormat.format(savingBalance)); |
| 104 | + } |
| 105 | + else{ |
| 106 | + System.out.println("No Money to Deposit"); |
| 107 | + } |
| 108 | + } |
| 109 | + |
| 110 | +} |
0 commit comments