Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedLISTING 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Beyond Greed And Fear Understanding Behavioral Finance And The Psychology Of Investing

Authors: Hersh Shefrin

1st Edition

0195161211, 978-0195161212

Students also viewed these Databases questions