write a program to calculate compound interest
Answers
The given problem is solved using language - Java.
import java.util.Scanner;
public class Brainly{
public static void main(String s[]){
Scanner sc=new Scanner(System.in);
double p,r,t,a,ci;
System.out.print("Enter Principal Amount: ");
p=sc.nextDouble();
System.out.print("Enter Rate Percentage (per annum): ");
r=sc.nextDouble();
System.out.print("Enter Time Period in years: ");
t=sc.nextDouble();
a=p*Math.pow(1+r/100.0,t);
ci=a-p;
ci=Math.round(ci*100)/100.0;
System.out.println("The Compound Interest Earned: "+ci);
}
}
To calculate compound interest, we have to calculate the amount first. It is calculated by using the formula given below:
Now, Compound Interest is calculated using formula given below:
Here, we have just taken the required values as input and using formula, compound interest is calculated.