Java代写 | Adding Inheritance to the Loan Calculator Program | CS代写

Java代写,在上一次assignment的Loan Calculator基础上实现功能,模拟bank流程,使用netbeans开发。

Assignment 3: Adding Inheritance to the Loan Calculator Program

In this programming assignment, we expand on the concept of the Loan Calculator.  Pretend you work for a bank. You have been asked to make an online savings calculator, where customers can calculate the value of their money after interest compounds for a number of periods.  You must prompt the user for a beginning principal (deposit amount), rate of interest per period, and number of periods with JOptionPane.  Compute interest for the periods that the user entered.  After computing interest for all periods, you must then display, via System.out.println(); the interest earned and principal balance.

The interest must compound once at the end of the period (only once per period, don’t compound more than that).

Create a project named calculator in your IDE.  This will be the package for your class.  This programming assignment has one superclass (Account), three subclasses (Checking, Savings, and CertificateOfDeposit), and one main class (Banker).

Make a class hierarchy that contains the following classes:

Class Account

Accessible attributes (instance fields, variables) should have at least:

  • principal
  • rate
  • period

accessible methods should include at least:

  • calculate
    • You should compute interest earned in this method, using this formula: principal = (principal * rate) + principal;

Class Savings extends Account

Should inherit these attributes from the superclass Account.  In other words, do not re-define them in the class Savings.

  • principal
  • rate
  • period

accessible methods should include at least:

  • calculate
    • You should inherit this method from Account.  You do not need to override it.

Class Checking extends Account

Should inherit these attributes from superclass Account:

  • principal
  • rate
  • period

Should define these attributes and getters/setters locally in the class Checking:

  • check number
  • monthly fee

Should contain a method named:

  • calculate

Class CertificateOfDeposit extends Account

Should inherit these attributes from Account:

  • principal
  • rate
  • period

Should define this attribute locally, in class CertificateOfDeposit:

  • length (to maturity; in months)  You do not need to use this in your calculations.  You simply need to collect it from the user and store it in an attribute.

Should inherit this method from superclass Account:

  • calculate

Class Banker

  • All user input/output should occur in this class.  There should not be any JOptionPane.showInputDialog in Savings, Checking, or CD.
  • Prompt the user for an account to open – Checking, Savings, or CD.
  • Prompt for beginning balance, interest rate, number of periods (length).  Pass these to the constructor of the appropriate object which you are creating.  So, each object should have at least one constructor that takes these three variables: beginning balance (principal), interest rate (rate), length.
  • If checking, prompt for first check number.  Make fee = 5.
  • If CD, prompt for length until maturity.
  • Repeat the process – ask if the user would like to open another account, until the user types stop (or something else that indicates that he/she is finished).
  • Save each account in a List of some type an array, ArrayList, or Vector.
  • When finished, call the calculate method on each account.  Display the same data described in assignment 1.  In other words, print period number, interest earned, and ending balance for each period.
  • If the account is a checking account, subtract the monthly fee from principal on each period in which interest is computed.

Other Criteria

  • Do something extra.  For example, you may want to validate data the user enters.
    • Interest Rate may be no greater than 25% (as a decimal or whole number, depending upon how you collect data).
    • Check number cannot be negative.
  • Comment

Hints

  • Use JOptionPane.showInputDialog(“your prompt message here”); to gather the three inputs, one prompt per input, for a total of three prompts.  Store the value of these prompts in variables.
  • Use a loop to iterate through each period.  Inside that loop, use this formula to calculate the ending balance:
    • principal = (principal * rate) + principal;
  • Don’t forget, since interest compounds once per period, you must make the principal at the end of the period equal to the principal at the beginning of the period plus interest earned that period.  In other words, use the formula above, don’t re-use the beginning principal amount each time.  The ending principal should increase over time.
  • You may need to convert variable types.  For example, the inputs come as Strings, but you will want to change them to floats or ints.  Look up the Integer and Float classes on the API Documentation for more information.

 


程序代写代做C/C++/JAVA/安卓/PYTHON/留学生/PHP/APP开发/MATLAB


本网站支持淘宝 支付宝 微信支付  paypal等等交易。如果不放心可以用淘宝交易!

E-mail: [email protected]  微信:dmxyzl003 工作时间:全年无休-早上8点到凌晨3点


如果您使用手机请先保存二维码,微信识别。如果用电脑,直接掏出手机果断扫描。

发表评论