Programming Assignment #8 (ArrayLists) A banking institution offers certificates
ID: 3555219 • Letter: P
Question
Programming Assignment #8
(ArrayLists)
A banking institution offers certificates of deposit (CD's) with a variety of interest rates, and maturities of 1, 3, 5, and 10 years. Interest is always compounded, daily, monthly, or quarterly.
Write a Java program that will monitor the growth, at yearly intervals, of any number of such CD's. Assume that a year always consists of exactly 365 days.
Begin by creating a class to model a CD. Each CD object "knows" its own principal, interest rate, maturity, and compounding mode (private instance variables). The class has
Explanation / Answer
import java.util.ArrayList;
import java.io.*;
import java.util.*;
class CD
{
private String time;
private double cdAmount;
private int cdMonths;
private double cdInterest;
public CD(String time, double cdAmount, int cdMonths, double cdInterest)
{
this.time = time;
this.cdAmount = cdAmount;
this.cdMonths = cdMonths;
this.cdInterest = cdInterest;
}
public String getTime()
{
return time;
}
public double CDAmount()
{
return cdAmount;
}
public int CDMonths()
{
return cdMonths;
}
public double CDInterest()
{
return cdInterest;
}
}
class CDlist
{
private ArrayList<CD> list;
public CDlist()
{
list = new ArrayList<CD>();
}
public void addList(CD info)
{
list.add(info);
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.