Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem Description and Given Info You must write a public abst ract class named BankAccount with fields and methods as defined below. UML CLass Diagram:

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Problem Description and Given Info You must write a public abst ract class named BankAccount with fields and methods as defined below. UML CLass Diagram: BankAccount Structure of the Fields As described by the UML Class Diagram above, your BankAccount class must have the following fields: - a protected field named accountID of type String, initialized to "0000-0000-0000-0000" - a protected field named interestRate of type double, initialized to 0.0 - a protected field named balance of type int, initialized to 0 Structure of the Methods As described by the UML Class Diagram above, your BankAccount class must have the following methods: - a public method named credit that takes an int argument and returns a boolean - a public abstract method named debit that takes an int argument and returns a boolean - a public method named getBa lance that takes no arguments and returns an int - a public method named getAccountID that takes no arguments and returns an String - a public method named setAccountID that takes a String argument and returns nothing - a public method named getInterestRate that takes no arguments and returns a double - a public method named setInterestRate that takes a double argument and returns nothing - a public abstract method named applyinterest that takes no arguments and returns nothing - a public abstract method named accountInfo that takes no arguments and returns a String Behavior of the Methods - The credit method should add the argument amount to the ba lance - The debit method is abstract so there will be no behavior or method body - The getBalance method should return the balance - The getAccountID method should return the accountID - The setAccountID method should store the argument value in the accountID field - The getBalance method should return the balance - The getinterestRate method should return the interestRate - The setInterestRate method should store the argument amount in the interestRate field - The applyInterest method is abst ract so there will be no behavior or method body - The accountinfo method is abst ract so there will be no behavior or method body Additional Information - Since this is an abstract class, you will not be able to instantiate any object from it. - You are given a TestAccount class that inheritslextends the BankAccount class. you may use this to help with testing your BankAccount class. - You are also given a Main class with a main method where you can write code to test your BankAccount class. All Bank Accounts 1. All accounts have balance, credit and debit amounts, and fees stored and passed as a number of pennies (int). 2. All debit amounts will be subtracted from the balance, and all credit amounts will be added to the balance. 3. All bank accounts have a non-negative interest rate (0.02 would be a 2% interest rate). 4. The credit method will always return true. Downloadable files BankAccount.java , TestAccount.java , and Main.java Download Current file: Main.java Load default template.. File is marked as read only Current file: TestAccount.java Current file: BankAccount Current file: BankAccount.java Load default template... \} @0verride public boolean debit(int pennies) \{ this. currentBalance = pennies; if (currentBalance 0 ) \{ currentBalance += currentBalance * (interestRate / 100); \} \} @0verride public void applyInterest() \{ if (currentBalance >0 ) \{ currentBalance += currentBalance * (interestRate / 100); \} \} @0verride public void accountInfo() \{ System.out.println("Type of Account: " + getClass().getSimpleName()); System.out.println("Account ID: " + accountID); System.out.println("Current Balance: \( \$ " \)quot; + currentBalance); System.out.println("Interest Rate: " + interestRate + "\%"); System.out.println("0verdraft Fee: \( \$ "+ \)quot;+ overdraftFee); \} \}

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

What Is A Database And How Do I Use It

Authors: Matt Anniss

1st Edition

1622750799, 978-1622750795

More Books

Students also viewed these Databases questions

Question

Explain the various techniques of Management Development.

Answered: 1 week ago