Question: 15. Given the following program: public class Bank { public static void main (String[] args){ BankAccount myAccount = new BankAccount(); myAccount.deposit(200); myAccount.withdraw(150); System.out.println(Your balance is:

15. Given the following program:

public class Bank {

public static void main (String[] args){

BankAccount myAccount = new BankAccount();

myAccount.deposit(200);

myAccount.withdraw(150);

System.out.println(Your balance is: + myAccount.getBalance() );

}

}

Complete the BankAccount class outlined below by filling in the method bodies based on the comments:

public class BankAccount {

private double balance;

/**

Increase the balance of the bank account by the amount specified in 'amount' but only if amount is greater than zero.

*/

public void deposit (double amount){

}

/**

Decrease the balance of the bank account by the amount specified in 'amount' but only if the operation would not result in a negative balance

*/

public void withdraw (double amount){

}

/**

Return the current balance of the bank account

*/

public double getBalance (){

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!