# Answer to Question #19985 in Java | JSP | JSF for shalenee

Question #19985

7. If you invest the amount of P at R% interest rate annually. In N years, your investment will be P[1-(R/100)N+1] / (1 – R/100). Accepts the input of P, R and N and compute the amount of money earned after N years using computer currency format.

(Note: Math.pow(A,B) - A raise to the power of B)

(Note: Math.pow(A,B) - A raise to the power of B)

Expert's answer

import java.util.Scanner;

public class main

{

/**

* Ifyou invest the amount of P at R% interest rate annually.

* In Nyears, your investment will be P[1-(R/100)N+1] / (1 – R/100).

* Accepts the input of P, R and N and compute the amount of money earnedafter N years using computer currency format.

* (Note: Math.pow(A,B) - A raise to the power of B)

*

*/

publicstatic void main(String[] args)

{

Scannerin=new Scanner(System.in);

//acceptsP

System.out.println("enterP (example: 100 or 100,1)");

doubleP=in.nextDouble();

//acceptsR

System.out.println("enterR (example: 1 or 0,1)");

doubleR=in.nextDouble();

//acceptsN

System.out.println("enterN");

intN=in.nextInt();

doubleamount=(P*(1-(R/100)*N+1))/(1-R/100);// P[1-(R/100)N+1] / (1 – R/100)

System.out.println(amount);

}

}

public class main

{

/**

* Ifyou invest the amount of P at R% interest rate annually.

* In Nyears, your investment will be P[1-(R/100)N+1] / (1 – R/100).

* Accepts the input of P, R and N and compute the amount of money earnedafter N years using computer currency format.

* (Note: Math.pow(A,B) - A raise to the power of B)

*

*/

publicstatic void main(String[] args)

{

Scannerin=new Scanner(System.in);

//acceptsP

System.out.println("enterP (example: 100 or 100,1)");

doubleP=in.nextDouble();

//acceptsR

System.out.println("enterR (example: 1 or 0,1)");

doubleR=in.nextDouble();

//acceptsN

System.out.println("enterN");

intN=in.nextInt();

doubleamount=(P*(1-(R/100)*N+1))/(1-R/100);// P[1-(R/100)N+1] / (1 – R/100)

System.out.println(amount);

}

}

Need a fast expert's response?

Submit orderand get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

## Comments

## Leave a comment