write a Java Program for to enter principal amount, rate of interest and time. Calculate and print the Simple interest and compound interest and difference between them.
Answers
Answered by
79
import java.util .*;
public class sici
{
public static void main (String args[ ])
{
double pr, rate, t, si,ci;
Scanner sc=new Scanner (System. in); System.out.println("Enter the amount:"); pr=sc.nextDouble();
System. out. println("Enter the No.of years:"); t=sc.nextDouble();
System. out. println("Enter the Rate of interest");
rate=sc.nextDouble();
si=(pr * t * rate)/100;
ci=pr * Math.pow(1.0+rate/100.0,t) - pr; System.out.println("Simple Interest="+sim); System.out. println("Compound Interest="+com);
}
}
public class sici
{
public static void main (String args[ ])
{
double pr, rate, t, si,ci;
Scanner sc=new Scanner (System. in); System.out.println("Enter the amount:"); pr=sc.nextDouble();
System. out. println("Enter the No.of years:"); t=sc.nextDouble();
System. out. println("Enter the Rate of interest");
rate=sc.nextDouble();
si=(pr * t * rate)/100;
ci=pr * Math.pow(1.0+rate/100.0,t) - pr; System.out.println("Simple Interest="+sim); System.out. println("Compound Interest="+com);
}
}
Prince0711:
For difference you just need to initialize a variable with name diff and store diff=si-ci; and print it.
Similar questions