Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

a. Create a class named BankAccount with fields that hold an account number, the owners name, and the account balance. Include a constructor that initializes

a. Create a class named BankAccount with fields that hold an account number, the owner’s name, and the account balance. Include a constructor that initializes each field to appropriate default values. Also include methods to get and set each of the fields. Include a method named deductMonthlyFee() that reduces the balance by $4.00. Include a static method named explainAccountPolicy() that explains that the $4 service fee will be deducted each month. Save the class as BankAccount.java.

 
b. Create a class named TestBankAccount whose main() method declares four BankAccount objects. Call a getData() method three times. Within the method, prompt a user for values for each field for a BankAccount, and return a BankAccount object to the main() method where it is assigned to one of main()’s BankAccount objects. Do not prompt the user for values for the fourth BankAccount object, but let it continue to hold the default values. Then, in main(), pass each BankAccount object in turn to a showValues() method that displays the data, calls the method that deducts the monthly fee, and displays the balance again. The showValues() method also calls the method that explains the deduction policy. Save the application as TestBankAccount.java.

Step by Step Solution

3.47 Rating (163 Votes )

There are 3 Steps involved in it

Step: 1

import javautil import javalang import javaio public class BankAccount int accountNumber String ownerName int accountBalance public BankAccountint acc... 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

Java Programming

Authors: Joyce Farrell

9th edition

1337397075, 978-1337397070

More Books

Students also viewed these Programming questions