Write a program to input/assign the values of principal p, rate r and time t, and display the simple
interest and amount at the end of the given time period
Answers
Explanation:
Simple Interest - Java
We need to first take User Input for the values of Principal Amount (P), Rate of Interest (R) and Time Period (T). We will do this by using Scanner.
We store them as double type values. Then, we calculate the Simple Interest using the formula and display it.
\rule{300}{1}
import java.util.Scanner; //Importing Scanner
public class SimpleInterest //Creating Class
{
public static void main(String[] args) //The main function
{
Scanner scr = new Scanner(System.in); //Creating Scanner Object
//Take User Input for P, R and T
System.out.print("Enter Principal Amount (P): ");
double P = scr.nextDouble();
System.out.print("Enter Rate of Interest (R): ");
double R = scr.nextDouble();
System.out.print("Enter Time Period (T): ");
double T = scr.nextDouble();
//Calculate Simple Interest I = (PRT)/100
double I = (P*R*T)/100;
//Display the Simple Interest
System.out.println("Simple Interest = "+I);
}
}