# Interest Program

• April 28th, 2014, 05:28 PM
Roisin
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;
//input
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();

//processing
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.
• April 29th, 2014, 02:57 AM
GregBrannon
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.