Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please update and explain in detail the bug on my Java code to display given output. public class Bank { private int Pin; protected double

Please update and explain in detail the bug on my Java code to display given output.

public class Bank {

private int Pin; protected double Balance;

public Bank() { Pin=0; Balance=0.0; try { // try catch block if (pin > 4) { throw new Exception(); } }catch (Exception ex) {// if any exception handle it System.out.println("The PIN number should be 4 digits"); } } public int getPIN() { return Pin; } public int setPIN(String string) { return Pin; } public String getBalance() { return Balance; } public void deposit(double amount) { if (amount > 0) { this.Balance += amount; this.Balance = Math.round(this.Balance * 100.0) / 100.0; } else { System.out.println("Cannot deposit a negative amount."); } } public void withdraw(double amount) { this.Balance -= amount; this.Balance = Math.round(this.balance * 100.0) / 100.0; } }

public class Check extends Bank{ protected static final double OVER=250.00; protected static final double MFEE = 15.0; protected static final double OFEE = 10.0; public Checking(int Pin, double Balance) { super(Pin, Balance); } @Override public void withdraw(double amount) { if (this.Balance - amount >= -OVER) { super.withdraw(amount); if (this.Balance

public class Test {

public static void main(String[] args) { Check dep = new Check(); dep.setPIN("64587"); dep.setPIN("0275"); dep.deposit(100.8); dep.withdraw(200.8); dep.getBalance("0275"); dep.withdraw(90); dep.getBalance("0275"); System.out.println("------------------"); dep.monthElapsed(1); dep.getBalance("0275"); dep.deposit(2000); dep.monthElapsed(5); dep.getBalance("0000"); dep.getBalance("0275"); System.out.println("------------------");

}

}

Expected Output:

image text in transcribed

The PIN number should be 4 digits. Current balance of your checking account: $110.00. Current balance of your checking account: \$-210.00. Current balance of your checking account: \$-225.00. You need to enter the correct PIN number to check your balance. Current balance of your checking account: $1775.00

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions