Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Interest Program

  1. #1
    Junior Member
    Join Date
    Apr 2014
    Thanked 0 Times in 0 Posts

    Default Interest Program

    I'm trying to learn java and came across a question online that I can't solve? Could anyone help me?
    Q.John has $500 to invest. Sue knows of a mutual fund plan that pays 10% interest, compounded quartely(that is, every 3 months, the principal is multiplied by 2.5% and the result is added to the principal).

    Write a program that will tell John how much money will be in the fund after 20 years.

    Make the program general:

    That is, it should take as inputs the interest rate, the initial principal, and the number of years to stay in the fund.

    The output should be in columns are the year number, the principal at the bgining of the year, the interest earned, and the principal at the end of the year.

    I'm not sure how to go about this could anyone give me the code so I can figure out what im doing wrong.

    CODE: public static void main(String[] args) {
    // TODO code application logic here
    double initialPrinciple;
    double interestRate;
    double totalYears;
    double lastPrinciple;
    double interestEarned;
    System.out.println("Enter initial Principle");
    Scanner sc = new Scanner(System.in);
    initialPrinciple = sc.nextDouble();
    System.out.println("Enter the number of years to be invested");
    totalYears = sc.nextDouble();
    System.out.println("Enter the Yearly Interest Rate");
    interestRate = sc.nextDouble();

    interestEarned = initialPrinciple * interestRate / 100;
    lastPrinciple = interestEarned + initialPrinciple;

    System.out.println("Years\t\t Initial Principal\t\tInterest Earned\t\tFinal Principal");

    System.out.println(+ totalYears + "\t\t\t" + initialPrinciple + "\t\t\t\t" + interestEarned +lastPrinciple);


    It would be really appreciated I am only a very new beginner.
    Thank you.

  2. #2
    Super Moderator
    Join Date
    Jun 2013
    So. Maryland, USA
    My Mood
    Thanked 698 Times in 680 Posts

    Default Re: Interest Program

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    Please post your code correctly.

    Future value, compound interest, payment calculators, etc. are all driven by relatively simple formulas that you just plug values into and compute. If the source of the question does not provide the formulas, you can search for them online.

Similar Threads

  1. Interest Calculator Design
    By heyya99 in forum Object Oriented Programming
    Replies: 4
    Last Post: April 10th, 2013, 08:07 AM
  2. How to Compute Interest
    By salsera1908 in forum Object Oriented Programming
    Replies: 5
    Last Post: December 4th, 2012, 02:38 PM
  3. Interest calculator applet
    By bruizer in forum Java Applets
    Replies: 4
    Last Post: September 22nd, 2012, 08:38 PM
  4. investment interest display problem
    By df75douglas in forum What's Wrong With My Code?
    Replies: 3
    Last Post: June 4th, 2011, 07:32 AM