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

  Write program to merge two files that contain polynomials

Write a program that merges two files that contain polynomials. To merge two files, the input files must be in sorted order.

  Explaining data-driven multicast routing paradigm

The data-driven multicast routing paradigm works best on local networks that have low delay and excess capacity, while the demand driven paradigm works best in a wide are environment.

  Why small to medium sized firm implement pki solution

Why would a small to medium sized firm implement a PKI solution? What are the characteristics required in using a password that will provide security protection for a company?

  Writing script for fahrenheit in celsius temperature

Use functions to write script which enables user to enter either Fahrenheit temperature and display Celsius equivalent or enter Celsius temperature.

  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.

  Communicate with a pc using the rs232c serial protocol

In this assignment we will use the UART0 peripheral to communicate with a PC using the RS232C serial protocol.

  Software system to manage records of patients

A software system is to be developed to manage the records of patients who enter a clinic for treatment. The records include records of the all regular patient monitoring.

  Write program to read integers and finds largest of them

Write a program that reads integer, finds the largest of them, and counts its occurrences. Assume thant the input ends with number 0. suppose that you entered 3 5 3 5 5 5 0.

  Write class postfixevaluator to evaluate postfix expression

Write a class PostFixEvaluator that evaluates postfix expression such as 6 2 + 5 * 8 4 / -. Program must read a postfix expression consisting of digits and operators into a StringBuffer.

  Create class to include fields for length-width in inches

Create a class name Tape that includes fields for length and width in inches and properties for each field. Also include a ToString () method that returns a string constructed from the return value

  Pseudocode for a program to solve mathematical problem

Pseudocode for a program to solve the following problem. A student borrows $3,000 at an interest rate 2% per month on the unpaid balance.

  Write code for largest value of parking tickets

Without using any additional variables, and without changing the values of ndays or the elements of the parkingTickets array, write some code that results in mostTickets containing the largest value found in parkingTickets .

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