Advertisement
Shekhar777

Java Compound interest

Oct 19th, 2020
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1. Q9-Write a program to find the compound interest for given principal amount P, time Tm(in years), and interest rate R.
  2. Ans-import java.io.*; // for handling input/output
  3. import java.util.*; // contains Collections framework
  4.  
  5. // don't change the name of this class
  6. // you can add inner classes if needed
  7. class Main {
  8.     public static void main (String[] args) {
  9.                       // Your code
  10.         Scanner sc=new Scanner(System.in);
  11.         int P=sc.nextInt();
  12.         int R=sc.nextInt();
  13.         int Tm=sc.nextInt();
  14.        
  15.    
  16.         double A=(P*(Math.pow((1+R/100.0),Tm)));
  17.         double CI;
  18.          CI=A-P;
  19.          String ans=String.format("%.2f",CI);
  20.         System.out.print(ans);
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement