write the program to calculate simple interest in java
Answers
Answer:
JAVA
public class Main.
{
public static void main (String args[])
{ float p, r, t, si; // principal amount, rate, time and simple interest respectively.
p = 13000; r = 12; t = 2;
si = (p*r*t)/100;
System.out.println("Simple Interest is: " +si);
}}
Simple Interest - Java
Simple Interest is the method of calculating the interest amount for a particular principal amount of money at some rate of interest.
The basic formula to calculate Simple Interest is as follows:
Where, P denotes Principal Amount, R denotes Rate of Interest and T denotes Time Period.
First we would take user input to accept the values of Principal Amount, Rate of Interest and Time Period. And we'll store them as double type values.
And after this, we'll calculate Simple Interest by simply using the formula of Simple Interest.
SimpleInterest.java
import java.util.Scanner;
public class SimpleInterest
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter Principal Amount: ");
double P = sc.nextDouble();
System.out.print("Enter Rate of Interest: ");
double R = sc.nextDouble();
System.out.print("Enter Time Period: ");
double T = sc.nextDouble();
double SI = (P*R*T)/100.0;
System.out.println("The Simple Interest is: "+SI);
}
}
Note: Do not copy-paste the exact cօde and run it, there are some white-space and no-space characters that will need to be removed before use, I've entered them for the sake of showing indentations in the cօde.