Write a Java program to find the Simple Interest and compound interest
Answers
Answer:
import java.util .*;
class sici
{
public static void main (String argu[ ])
{
double pr, rate, t, sim,com;
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();
sim=(pr * t * rate)/100;
com=pr * Math.pow(1.0+rate/100.0,t) - pr;
System.out.println("Simple Interest="+sim);
System.out. println("Compound Interest="+com);
}
}
Please mark as BRAINLIEST!! Good Luck :)))
Explanation:
this is a Java Program to Find the Simple Interest.
Formula:
Simple Interest = (Principal * Rate * Time)/100
Enter the principal, rate of interest and time period as input. Now we use the given formula to calculate the simple interest.
Here is the source code of the Java Program to Find the Simple Interest. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
advertisement
import java.util.Scanner;
public class Simple_Interest
{
public static void main(String args[])
{
float p, r, t;
Scanner s = new Scanner(System.in);
System.out.print("Enter the Principal : ");
p = s.nextFloat();
System.out.print("Enter the Rate of interest : ");
r = s.nextFloat();
System.out.print("Enter the Time period : ");
t = s.nextFloat();
float si;
si = (r * t * p) / 100;
System.out.print("The Simple Interest is : " + si);
}
}
Output:
$ javac Simple_Interest.java
$ java Simple_Interest
Enter the Principal : 20202
Enter the Rate of interest : 2.5
Enter the Time period : 3
The Simple Interest is : 1515.15