Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java inheritance exercise Pursose: This exercise allows you to implement inheritance and polymorphism. Description Write a bank a Bank Account project according to the following

Java inheritance exercise

Pursose:

This exercise allows you to implement inheritance and polymorphism. Description Write a bank a Bank Account project according to the following specifications: Bank Account: Every bank account has an identifier, a PIN, and a balance. Every bank account should have a way to deposit an amount, withdraw an amount(abstract method), and display the current balance. Ensure that any class that inherits from this class has a withdraw() method that overrides the abstract withdraw() method.

Savings:

The withdraw method will only let the owner withdraw if the funds are sufficient. If the owner attempts to withdraw an amount higher than the balance, print an error message and do not process the withdraw.

Checking:

The withdraw method should withdraw the amount only if the funds are availible, and apply a service fee of $0.25 for each withdrawal to the balance. If the owner. if the owner attempts to withdraw more than the balance of the account, print an error message and do not process the withdraw.

CheckingPlus:

The withdraw method will allow the owner to withdraw more than the balance up to a predefined limite(the limit is a field in the class, the numer I used was 1000) If the amount requested is approved the fee is applied. The fee is a percentage of the amount overdrawn(ex: 10%). If the limit is exceeded, throw and catch the error.

Testing:

In main() create an array of five BankAccounts objects and each account will have a unique ID. Then allow the user to enter the BankAccount ID and PIN to either deposit or withdraw an amount. After each transaction, display the current balance. if the account ID with the PIN number is wrong, print an error message to the user and ask for another ID and PIN.

In my code, I keep failing in my testing phase and the Unique IDs are not being found. I will attach all my files if I can find out how to do so. Any help will be very appreciated and highly rated!

Edit: I am attaching the part of my code in my driver that is giving me trouble. If there is a better way to find the ID's please let me know!image text in transcribed

public class Driver public static void main (String [1 args) [] acts= new BankAccount [5]; BankAccount Scanner kb=new Scanner (System.in); kb2= new Scanner (System.in); found=false Scanner boolean found-falsei boolean acts [O]=new Checking (01234, 4748, 1000000); acts [1]= new Checking (12345, 5555, 20000); acts [2]=new Savings (23456, 3333, 5562214.36); acts [3]=new Checking (34567,4444, 789456.21); acts [4]= new CheckingPlus (45678, 6666, 12.11); System.out.println (acts[3].id) System.out.printin("please enter your int id= kb. nextInt(); int account=0; for (int i=0; i

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

Database Design And SQL For DB2

Authors: James Cooper

1st Edition

1583473572, 978-1583473573

Students also viewed these Databases questions