• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

New to ArrayList

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, im new to ArrayList and im having great trouble trying to figure things out,
this is what im supposed to do:
The Problem

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 compute the accumulated value (principal plus interest earned), at yearly intervals, of any number of such CD's. Assume that a year always consists of exactly 365 days.

Output will be a series of 10 annual reports:

Reports will be in table form with appropriate column headings. There will be one row of the table for each active CD, which will include all the data along with the accumulated value and total interest earned to data.

Each report will also print the total interest earned by all CDs for the current year, and total interest earned by all active CD�s to data.

Once a CD reaches maturity, it will stop earning interest and will not appear in any future reports. E.g., a CD with a maturity of 5 years will appear in the reports for years one through five, but not thereafter.

The CD Class

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 �get� methods to return this data and a method to compute and return the accumulated value.

The CDList Class

Now create a class to maintain a list of CDs. You will need methods to add a CD to the list and to print the annual report.

The Driver (i.e., "Test") Class

Your test class or "driver" class will read data for any number of CDs from a file that I will supply. Each line of the file will contain the data � principal, interest rate (as an annual per cent), maturity, and compounding mode � for one CD.

First, tokenize each line read, create a CD object from the tokens, and add it to the list. Then print the reports.

Additional Specifications

Your CDList class must use an ArrayList as the principal (no pun intended) data structure.

Your test class is to read the data file one time only. No credit will be given for programs that read the data file more than once.

Make sure your program is well documented and adheres to the style conventions discussed in class.


Due date:Thursday, April 20th


Formula

The accumulated value (i.e., principal plus interest), A, is given by the formula:

r nt
A = p ( 1 + ���� )
n

where

p = principal

n = number of times compounded per year

r = annual interest rate, expressed as a decimal

t = elapsed time in years

now, im supposed to read data from a file, and whats inside the file is:
5000 5 8.25 quarterly
12000 10 10.80 daily
2000 5 7.30 quarterly
10000 3 5.55 monthly
2000 1 4.50 daily
5000 10 9.15 monthly

now, im totally lost, however, ive managed to do this so far:

Please any help regarding this subject will be greatly appreciated.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are you "totally lost" with? It looks like you correctly instantiated an array list. It looks like you correctly used it to add items.

It would help us, if you tell us, what about the ArrayList class that you don't understand.

Henry
 
apollo abel
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, lets take this step by step,
it says that in the cd class im supposed to have:
Each CD object "knows" its own principal, interest rate, maturity, and compounding mode (private instance variables)"
1. i have 4 variables, am i missing something in the CD class?

2. the cdlist class is supposed to have this:
"Now create a class to maintain a list of CDs. You will need methods to add a CD to the list and to print the annual report."

i have created an empty list, do i need to add the 4 variables into the list ive created??

3. the test class says this:
"Your test class or "driver" class will read data for any number of CDs from a file that I will supply. Each line of the file will contain the data � principal, interest rate (as an annual per cent), maturity, and compounding mode � for one CD.

First, tokenize each line read, create a CD object from the tokens, and add it to the list. Then print the reports."

well i dont know how to do this, but ill try not to worry about this now.
 
Arthur, where are your pants? Check under this tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic