Write a program in Jave to calculate and display simple interest by accepting principal amount, time and rate of interest using function argument
Answers
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.
Main.java
import java.util.Scanner;
public class SimpleInterest
{
public static void main(String[] args)
{
Scanner scr = new Scanner(System.in);
System.out.print("Enter Principal Amount: ");
double P = scr.nextDouble();
System.out.print("Enter Rate of Interest: ");
double R = scr.nextDouble();
System.out.print("Enter Time Period: ");
double T = scr.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.
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.
Main.java
import java.util.Scanner;
public class SimpleInterest
{
public static void main(String[] args)
{
Scanner scr = new Scanner(System.in);
System.out.print("Enter Principal Amount: ");
double P = scr.nextDouble();
System.out.print("Enter Rate of Interest: ");
double R = scr.nextDouble();
System.out.print("Enter Time Period: ");
double T = scr.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.