Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#Java program BankAccount SavingAccount AnnualInterestRate: double # accountName: String # account Number: int # account Balance: double + BankAccout() + BankAccount (accountName: String, accountNumber: int,

image text in transcribed

image text in transcribed

#Java program

BankAccount SavingAccount AnnualInterestRate: double # accountName: String # account Number: int # account Balance: double + BankAccout() + BankAccount (accountName: String, accountNumber: int, accountBalance: double) + SavingAccount() + SavingAccount (accountName: String, account Number: int, accountBalance: double AnnualInterestRate: double) + calculateMonthlyInterestRate(): double + toString(): String java.lang. Comparable K. + compareTo (o : Object): int Write a complete program for the SavingAccount class and test program based on the Figure 1 and the following requirements: Create a SavingAccount class that derived from BankAccount. This class inherits all data fields from its superclass and also has its own data field named AnnuallnterestRate. This data field is used to hold the value of annual interest rate. Besides that, the SavingAccount has two constructors, calculateMonthlyInterestRate() method and toString() method. The calculateMonthlyInterestRate() method returns the calculation result of monthly interest rate by using the following formula: AnnualInterestRate / 12 * accountBalance. The toString() method will return the information of SavingAccount object. The SavingAccount class will implement the compareTo() method from Comparable interface to compare the monthly interest rate of the two objects. This method returns 1 if the monthly interest rate of the first object is larger than the second object, return -1 if smaller than the second object and return O if both objects have the equal monthly interest rate. Write a test program that creates two objects of SavingAccount with any values of the accountName, account Number, accountBalance and AnnuallnterestRate. Display information for the both objects including the monthly annual interest and the result of comparison

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

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

More Books

Students also viewed these Databases questions