Question: LISTING 1.1 The bank.java Program // bank.java // demonstrates basic OOP syntax // to run this program: C>java BankApp //////////////////////////////////////////////////////////////// class BankAccount { private double

LISTING 1.1 The bank.java Program // bank.java // demonstrates basic OOP syntaxLISTING 1.1 The bank.java Program

// bank.java // demonstrates basic OOP syntax // to run this program: C>java BankApp //////////////////////////////////////////////////////////////// class BankAccount { private double balance; // account balance public BankAccount(double openingBalance) // constructor { balance = openingBalance; } public void deposit(double amount) // makes deposit { balance = balance + amount; } public void withdraw(double amount) // makes withdrawal { balance = balance - amount; } public void display() // displays balance { System.out.println("balance=" + balance); } } // end class BankAccount // ////////////////////////////////////////////////////////////////
class BankApp { public static void main(String[] args) { BankAccount ba1 = new BankAccount(100.00); // create acct System.out.print("Before transactions, "); ba1.display(); // display balance ba1.deposit(74.35); // make deposit ba1.withdraw(20.00); // make withdrawal System.out.print("After transactions, "); ba1.display(); // display balance } // end main() } // end class BankApp

NOTE: PLEASE, SCREENSHOT EACH OF YOUR TEST RUNS SHOWING YOUR PROGRAM WORKING SUCCESSFULLY AND ALSO FAILING THE TWO CONDITIONS I ASKED YOU TO CHECK. THE TWO CONDITIONS ARE: - FOR THE WITHDRAWAL MAKE SURE THERE ARE SUFFICIENT FUNDS - FOR THE DEPOSIT MAKE THE AMOUNT DEPOSITED IS A POSITIVE VALUE THE PROGRAM SHOULD PRINT OUT A MESSAGE IF EITHER OF THESE CASES ARE FOUND

Type in the Bank.java program from Listing 1.1 of the text using your own IDE. Modify the withdraw() method to add a check to make sure there are sufficient funds available before withdrawing. Also modify the deposit() method, to make sure the amount deposited is a positive value (>0). You should test your program by running it multiple time showing these new added test cases... Your program should print out a message if either of these cases are found

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!