Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

Create four classes: Account.java, Checking.java, Savings.java, and AccountArray.java.

1. For the Account class, create:

  • two protected variables for the account number and the account balance.
  • two get methods - one for the account number and one for the account balance
  • two set methods - one for the account number and one for the balance.
  • a constructor that requires an account number and sets the balance to 0.
  • a method to override the toString() method which returns a String containing: Account # = < account number> Account Balance = where is the object's account number and is the object's account balance.
  • an abstract computeInterest() method that takes one integer argument and returns a double.
  • Do not allow either the account number or the balance to be set to a negative number.

2. The Checking class will be a subclass of Account. For the Checking class, create:

  • a method to override the toString() method which returns a String containing: "Checking" , the account number, and the account balance. Do not print the interest earned as part of toString().
  • a constructor that takes an account number as an argument and calls the superclass constructor passing this account number.
  • a method to implement the abstract computeInterest() method of the superclass. This method takes one argument for the interest period and returns the interest earned. The interest earned is 2 % of the balance over $700 times the interest period. The interest period is passed as an argument to the computeInterest() method. For example, the interest on $3000 at 2% for three years is (3000 - 700) times .02 times 3 or 138.

3. The Savings class will be a subclass of Account. For the Savings class, create:

  • an additional private variable to hold the interest rate.
  • a get and set method for the interest rate. Do not allow the interest rate to be set to a negative number.
  • a method named toString() that overrides the toString() method of the Object class. This method should return "Savings", the account number, the account balance and the interest rate. Do not print the interest earned as part of toString().
  • a constructor with two arguments - the account number and the interest rate. This constructor calls the superclass constructor passing the account number.
  • a method to implement the abstract computeInterest() method of the superclass. This method takes one argument for the interest period and returns the interest earned. The interest is calculated as (1 + interest rate)period times the balance minus the balance. The interest period is passed as an argument to the computeInterest() method. For example, the interest on $6000 at 2% for three years is (1.02)3 * 6000 - 6000 or 367.

4. For the AccountArray class, create:

  • a main() method.
  • an array to store 10 objects of either the Savings or Checking class. Use 2% (.02) for the savings account rate. Use account numbers 100 through 109. Use initial balances of 1000 through 10000.
  • a for loop that will instantiate 5 objects of the Savings class and 5 objects of the Checking class. Store these objects in a single array created above.
  • a for loop that prints the data in all 10 objects of the array using the overridden toString() method and also prints the interest amount computed for each object. Use 3 for the period.

Java, Programming

  • Category:- Java
  • Reference No.:- M9132293
  • Price:- $30

Priced at Now at $30, Verified Solution

Have any Question?


Related Questions in Java

Can someone please help me with the following java

can someone please help me with the following java question The input is an N by N matrix of nonnegative integers. Each individual row is a decreasing sequence from left to right. Each individual column is a decreasing s ...

Object-oriented software development1 introduction 11

OBJECT-ORIENTED SOFTWARE DEVELOPMENT 1. Introduction 1.1 Assignment Requirement 1.2 Deliverables and Structure (what to submit) 1.3 Software Restrictions 1.4 How to score high... 1.5 Assumptions 2. System Requirements 2. ...

Can someone help me please with those question1what is the

Can someone help me please with those question 1:what is the best data type for student id datatime,currency,number,decimal 2:which relationshipis preferable? one to one,one to many,many to many 3:if you add table A's pr ...

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

Answer the following question whats the difference public

Answer the following Question : What's the difference public inheritance and private inheritance? What can derived classes inherit from base classes? What cannot be inherited from base classes?

Assessment instructionsin this assessment you will design

Assessment Instructions In this assessment, you will design and code a simple Java application that defines a class, instantiate the class into a number of objects, and prints out the attributes of these objects in a spe ...

Solving 2nd degree equationsbull write the following java

Solving 2nd degree equations • Write the following Java methods • boolean real-sols(double a, double b, double c): it returns true if the 2nd degree equation ax2 + bx + c has real solutions • double solution1(double a, d ...

Question slideshows or carousels are very popular in

Question : Slideshows (or carousels) are very popular in websites. They allow web developers to display news or images on the website in limited space. In this code challenge, you are required to complete the JavaScript ...

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As