Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please design and implement a Java class named BankAccount that supports the following operations: 1) to create an account with the account number (a string)

Please design and implement a Java class named BankAccount that supports the following operations: 1) to create an account with the account number (a string) and initial balance $0.0; 2) to deposit money; 3) to withdraw money; 4) to check balance; 5) to provide the account number; Use the attached Main class to test your class. The results should look like: ---------------------------------------- Balance in Account BA-123-001 is $0.0 Balance in Account BA-654-002 is $0.0 $100.0 is deposited to Account BA-123-001 $500.25 is deposited to Account BA-654-002 Low Balance. Operation is rejected. $40.0 is withdrawn from Account BA-654-002 Balance in Account BA-123-001 is $100.0 Balance in Account BA-654-002 is $460.25 ----------------------------------------- public class Main { public static void main(String[] args) { //create two accounts BankAccount account1 = new BankAccount("BA-123-001"); BankAccount account2 = new BankAccount("BA-654-002"); //check balance System.out.println("Balance in Account " + account1.getAccountNumber() + " is $" + account1.getBalance()); System.out.println("Balance in Account " + account2.getAccountNumber() + " is $" + account2.getBalance()); System.out.println(); // print an empty line //deposit account1.deposit(100); account2.deposit(500.25); System.out.println(); // print an empty line //withdraw account1.withdraw(150); account2.withdraw(40); System.out.println(); // print an empty line //check balance again System.out.println("Balance in Account " + account1.getAccountNumber() + " is $" + account1.getBalance()); System.out.println("Balance in Account " + account2.getAccountNumber() + " is $" + account2.getBalance()); } }

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

Marketing Database Analytics

Authors: Andrew D. Banasiewicz

1st Edition

0415657881, 978-0415657884

More Books

Students also viewed these Databases questions