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.

>> REGISTER NOW TO START POSTING

1. ## 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.

2. ## 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.