Results 1 to 5 of 5
  1. #1
    tfresc23 is offline Member
    Join Date
    Apr 2011
    Posts
    2
    Rep Power
    0

    Default not sure about how to right a Certificate Deposit class

    Create a class named CD to represent the certificate of deposit. It should store the following attributes (data):

    The term (or duration) of the CD in years
    The purchase price of the CD
    Both of these attributes are known when a CD is purchased. In your program assume that they never change after the CD is purchased. This means that they should be set through a constructor only (no "setter" accessor methods; no public data members).

    The class should provide a method named getRate() that returns the interest rate. The interest rate is determined by the term of the CD according to this table.

    Term Rate
    1 year 0.30%
    2 years 0.45%
    3 years 0.95%
    4 years 1.50%
    5 years 1.80%
    Because the interest rate is calculated by the CD class based on the term, there should be no setRate() method in the class. Also, there should be no class member variable to store the interest rate.

    In your constructor, if the number of years provided is less than one, set the value to one. If years is greater than five, then set it to five.

    Can anybody help me?

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default

    Yes we can help. No we won't do it for you. Do not dump your assigment on us and expect us to do it. You have to write the code. When your get stuck post your code, error messages and ask a specific question.

  3. #3
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    I'm sure a lot of people can help you.

    You need to put the effort in first, don't just dump the assignment. Let's see your first attempts, tell us what is giving you a hard time and ask specific questions. If you get errors, copy and paste them, do not paraphrase.

    Finally, use code tags when posting code. To do this wrap your code in code tags.
    [code ]
    YOUR CODE HERE
    [/code]

  4. #4
    tfresc23 is offline Member
    Join Date
    Apr 2011
    Posts
    2
    Rep Power
    0

    Default

    Im not a 100% sure but if you could tell me if I am doing it right?

    public class CD
    {
    private int y = 0;
    private int p = 0;
    private int r = 0;
    private int product;

    public CD( int Year, int Price,);
    {
    y = year;
    p = price;
    r = rate
    }

    public void setYear(int Year)
    {
    y = year;
    }

    public int getYear()
    {
    return y;
    }

    public void setPrice( int Price)
    {
    p = price;
    }

    public int getPrice()
    {
    return p;
    }

    public int getRate()
    {
    if (y = 1)
    {
    r = .3;
    }
    else if (y = 2)
    {
    r =.45;
    }
    else if (y = 3)
    {
    r = .95;
    }
    else if (y = 4)
    {
    r = 1.5;
    }
    else if (y = 5)
    {
    r = 1.8;
    }
    else
    {

  5. #5
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default

    Since your code doesn't compile I'm sure it is not correct. Read your error messages and correct the line of code it complains about. If you do not understand the message post the exact error message and indicate which line it occurs on.

Similar Threads

  1. Temporarily add CA certificate
    By ohm in forum Advanced Java
    Replies: 0
    Last Post: 02-15-2011, 12:07 PM
  2. Unwrapping a key using a certificate
    By alexag in forum New To Java
    Replies: 0
    Last Post: 12-15-2010, 12:40 PM
  3. SUN 310-813 certificate
    By koko12 in forum Java Certification
    Replies: 2
    Last Post: 11-24-2009, 05:33 PM
  4. HTTPS using certificate
    By MCJP in forum Advanced Java
    Replies: 1
    Last Post: 09-25-2008, 01:48 PM
  5. Java certificate
    By Nick15 in forum Java Certification
    Replies: 2
    Last Post: 11-12-2007, 06:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •