Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me write this code in java. I have attached the instructions and all the required codes. Exercise 1: Creating another subclass of BankAccount

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedPlease help me write this code in java. I have attached the instructions and all the required codes.

Exercise 1: Creating another subclass of BankAccount Download the BankAccount class and the CheckingAccount classes, and create a new project for these files Create a new savingsccount class in your project, which extends the BankAccount class. It will contain an additional attribute besides the one inherited from the BankAccount class: the interest rate (a double) for a savings account. It will also contain the following methods: . a constructor with two parameters public SavingsAccount (double initialAmount, double rate) e an accessor method for the interest rate public void calculateInterest), which calculates one month's interest and adds the amount to the balance * public string tostring(), which returns a string representation of the account's attributes (balance and interest rate) Exercise 2: Experimenting with inheritance Download the file TestBankAccounts.java and add it to your project. It has a main method that so far only creates some bank account objects of the three types BankAccount, Checkinghccount, and SavingsAccount In each step of this exercise, you will be adding statements to the main method, running it after each addition. Answer the questions at each step. If there is a compilation error, make sure you remove (or comment out) the offending statement before advancing to the next step of this exercise. Which method(s) of the class checkingAccount demonstrate overriding? Make the following changes to class TestBankAccounts (code must be added near the end of the main method, after the last comment line): . Add the statement bacco -chace, which makes the Bank Account vanable bacco reference the Checking Account Obje tre erenced by chac i was this , why . Now add below the above statement the following: system.out.println(bacco.tostring))and run. Which tostring method did it use, the one from the BankAccount class or the one from the CheckingAccount class? Why? compiles and runs, using casting Add the statement chacc1.deposit (100.0)i Your program should compile and run. Now make the following change to checkingAccount.java: in the code for the deposit method, change . Add a statement to make the variable chaccl reference the BankAccount object referenced by bacci, and compile. Was this legal? Why not? . Add the statement BankAccount bacc2 new Checkingaccount (200.0)i.Now suppose we want the variable chacci to reference this new object: add the statement chacci bacc2i. Fix this statement so that it . Add statements to invoke deductFees on objects of all three types (i e on variables bacc, chac! and sacel on which type ofo e ts as his legal w y? super.deposit(amount) to deposit (amount): Compile and run. What was the runtime error, and why do you think it happened

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_2

Step: 3

blur-text-image_3

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

Practical Database Programming With Visual C# .NET

Authors: Ying Bai

1st Edition

0470467274, 978-0470467275

More Books

Students also viewed these Databases questions

Question

What are Measures in OLAP Cubes?

Answered: 1 week ago

Question

How do OLAP Databases provide for Drilling Down into data?

Answered: 1 week ago

Question

How are OLAP Cubes different from Production Relational Databases?

Answered: 1 week ago