9. A certain amount is invested at the rate 10% per annum for 3 years. Find the
difference between Compound Interest (CI) and Simple Interest (SI). Write
program to take amount as an input.
Hint: SI = P*R*T
A = P*(1+R/100)T and CI= A-P
100 ,
AL
100
Answers
Answer:
import java.util.Scanner;
public class HelloWorld{
public static void main(String []args){
Scanner sc=new Scanner(System.in);
System.out.println("Enter Principal Amount :");
double p=sc.nextDouble();
double si = p*10*3/100;
double ci=p*1.1*1.1*1.1-p;
System.out.println("Difference between simple interest and compound interest is "+(ci-si));
}
}
Explanation:
Hope it helps :-)
(1 + R/100)^3 = (1 + 10/100)^3 = (1 + 0.1)^3 = 1.1 * 1.1 * 1.1
import java.util.Scanner;
public class HelloWorld{
public static void main(String []args){
Scanner sc=new Scanner(System.in);
System.out.println("Enter Principal Amount :");
double p=sc.nextDouble();
double si = p*10*3/100;
double ci=p*1.1*1.1*1.1-p;
System.out.println("Difference between simple interest and compound interest is "+(ci-si));
}
}