Programming Examples
Java program to input the Principal Rate and Time for a certain amount of money and print the Simple Interest
Write a program to input the Principal, Rate and Time for a certain amount of money and print the Simple Interest.
Solution
import java.util.*;
class SimpleInterest
{
public static void main(String arr[])
{
Scanner sc=new Scanner(System.in);
float p,r,t,si;
System.out.println("Enter the principal:");
p=sc.nextFloat();
System.out.println("Enter the rate:");
r=sc.nextFloat();
System.out.println("Enter the time:");
t=sc.nextFloat();
si=(p*r*t)/100;
System.out.println("Simple Interest="+si);
}
}
Output
Enter the principal:
5000
Enter the rate:
7.3
Enter the time:
5
Simple Interest=1825.0