write a java program to find the difference between simple(SI) and compound interest (CI) when principal rate and time are given :
Answers
Answer:
Explanation:
import java.util.Scanner;
public class JavaExample
{
public static void main(String args[])
{
float p, r, t, sinterest;
Scanner scan = new Scanner(System.in);
System.out.print("Enter the Principal : ");
p = scan.nextFloat();
System.out.print("Enter the Rate of interest : ");
r = scan.nextFloat();
System.out.print("Enter the Time period : ");
t = scan.nextFloat();
scan.close();
sinterest = (p * r * t) / 100;
System.out.print("Simple Interest is: " +sinterest);
}
import java.util.*;
public class Difference
{
public static void main (String args[])
{
Scanner in = new Scanner(System.in);
int p , r , t ;
double si, ci , d;
System.out.println("Enter the values of principal, rate and time :");
p = in.nextInt();
r = in.nextInt();
t = in.nextInt();
si = (p*r*t/100);
System.out.println("Simple Interest =" +si);
ci = Math.pow(p(1+r/100),t);
System.out.println("Compound Interest =" +ci);
d = (si - ci);
System.out.println("Difference between simple interest and the compound interest is =" +d);
}
}