Create inheritance hierarchy containing base class

Assignment Help Programming Languages
Reference no: EM1367777

Create an inheritance hierarchy containing base class Account and derived classes SavingsAccount and CheckingAccount that inherit from class Account. Make sure all fields, methods, and parameters are declared abstract, final, public, private, protected where appropriate.

Base class Account should include one data member of type double to represent the account balance. The class should provide aa constructor that receives an initial balance and uses it to initialize the data member. The constructor should validate the initial balance to ensure that it is greater than or equal to 0.0. If not, the balance should be set to 0.0 and the constructor should display an error message, indicating that the initial balance was invalid.

The class should provide several methods. Method credit should add an amount to the current balance. Method debit should withdraw money from the account and ensure that the debit amount does not exceed the account's balance. If it does, the balance should be left unchanged and the function should print an error message. Method getBalance should return the current balance.

Derived class SavingsAccount should inherit the funcionality of an Account, but also inclute a data member of type double indicating the yearly interest rate (percentage) assigned to the account. SavingsAccount's constructor should receive the initial balance, as well as an initial value for the SavingsAccount's interest rate. SavingsAccount should provide a method applyInterest that applies the interest rate of the account to its balance, increasing the balance.

Derived class CheckingAccount should inherit from base class Account and include an additional data member of type double that represents the fee charged per transaction. Its constructor should receive the initial balance, as well as a parameter indicating the fee. The credit and debit methods should be redefined to subtract the fee from the account balance whenever either transaction is performed successfully. Note that you must not duplicate code.

Remember to test your code extensively before submitting. Submit the three .java files containing the above classes.

Reference no: EM1367777

Questions Cloud

Asset market model and exchange rates. : Suppose the spot exchange rate in dollars and yen is e=$1/100yen. The interest rate on a 6 months dollar denominated assets is i($)=1 percent and interest rate on comparable 6 months yen denominated assets
Economics-decision making in multi-national firms : Can you articulate how macroeconomics and microeconomics come into play in the context of firm decision-making in a global business. Please provide an example.
Understanding of transcultural concepts : What unique features of families require an understanding of transcultural concepts? Describe factors the nurse will require to consider when planning culturally appropriate nursing care.
Underestimating actual costs : Assume the military bureaucracy consistently misinforms Congress on total costs of producing military hardware. Suppose that it underestimates the actual costs and that the political representatives believe these estimates.
Create inheritance hierarchy containing base class : Create an inheritance hierarchy containing base class Account and derived classes SavingsAccount and CheckingAccount that inherit from class Account.
Important information regarding nursing research : According to Polit and Beck (2006), nurses in different settings are adopting a research-based (or evidence-based) practice which incorporates research findings into their decisions and interaction with clients.
Determinants of demand or supply : Identify which of the determinants of demand or supply are affected and also indicate whether demand or supply increases or decreases.
Optimal price and output combination : Assume an airline flying on the New York - Chicago route has estimated the demand curves for three different types of customers: business (no advance purchase), leisure (7 day advance purchase), and discount (14 day advance purchase) travelers.
Determine the value of the spot rate : Assume that on January 1, 1999 spot exchange rate was Yen/£=198. Over the year, British inflation rate was 4 percent, and the Japanese inflation rate was 6 percent.

Reviews

Write a Review

Programming Languages Questions & Answers

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Creating method to union the interface for adt bag

Add method union to  interface BagInterface for ADT bag which returns as new bag the union of bag receiving call to method and bag which is the method's one argument.

  Pseudocode to create thread-safe countdownevent by locks

Write pseudocode to implement a thread-safe CountdownEvent using locks and condition variables by implementing the following methods (lists 4 methods) and then "implement a Barrier using a CountdownEvent.

  Program to compute percentage and final grade for students

Write a program which will permit teacher to compute percentage and final grade for students in a class.

  Write program to reads student-s name together with score

Write a program that reads a student's name together with his or her test score. The program should then compute the average test score for each student.

  Program to read from an input file

Write a program to read from an input file for 15 students, that contains each individual student ID, the course code, letter grade, and credit hours for five courses.

  Writing program of long term parking

Write an enitre program about the long term parking, and calculate the parking total fare.

  Develop an encryption program

Your employer, SGA (Secretive government Agency) wants you to develop an encryption program. After doing some research you have two candidate algorithms.

  Explain about lexical analyzer

Explain about Lexical Analyzer

  Explain importance of developing strategy for navigation

Discuss the importance of developing a strategy for the navigation, and describe the common navigation elements. Navigation is a very important part of your portfolio.

  Create a multi-threaded competition

Create a multi-threaded competition in which opposing Robin Hoods will attack one another and try to take each other's gold coins.

  Write pseudocode for determining grade of student

Write a pseudocode for determining the grade of a student given his/her total score. The program should display a grade of A if the score is above 85.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd