java - compound interest after 1, 3 and 5 years -


I have this code which calculates compound interest, but I should do it after 1, 3, and 5 years . Tried and cant seem to get it to work. Can anyone help me?

  import java.util.Scanner; Public class CompoundInterest {public static zero main (string [] args) {scanner input = new scanner (System.in); Double principal = 0; Double rate = 0; Double time = 0; Double x = 0; System.out.print ("Enter the amount invested:"); Principal = input. NXD double (); System.out.print ("Enter Interest Rates:"); Rate = input.nextDouble (); System.out.print ("Enter the time of the loan:"); Time = input.nextDouble (); X = Prime * Math ((+ 1 + rate / 12), time); X = Math. Pow (5,3); Println (""); System.out.println ("Compound interest after 1 year:" + x); }}  

You x to principal * ((1 + r / 12), time) , then set x = math.pow (5,3) ?

x is now set to math.pow (5,3) and nothing has to do with your principal, rate and time information.

In addition, you should specify that time is input year, because you have a hard code in the rate question.


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -