Let’s learn java program to find simple interest.
Java program to find simple interest
Simple interest is used to enumerate interest on loan in banks. It is calculated by using formula,
Simple Interest = (P x R x T) / 100
P – is principal amount.
R – is rate per annum.
T – is time in years.
For example – rohith deposits Rs 7000 INR in a bank at a interest rate of 7% per annum for 4 years. Now calculate the simple interest at the end of 4 years.
Simple interest at the end of 4 years is = 7000 * 7 * 4 / 100 = 1960
In the below simple interest program in java first user enters principal amount, rate and time in years using nextFloat() method of Scanner class.
These three values are stored in principal, rate and time variables of data type float.
Then finally calculate interest using above formula. Let’s see program to find simple interest.
import java.util.Scanner; public class SimpleInterestJavaProgram { public static void main(String[] args) { float principal, rate, time; Scanner sc = new Scanner(System.in); System.out.print("Enter principal amount : "); principal = sc.nextFloat(); System.out.print("Please enter rate annually : "); rate = sc.nextFloat(); System.out.print("Please enter time(in years) : "); time = sc.nextFloat(); float simpleInterest; simpleInterest = (principal * time * rate) / 100; System.out.println("The Simple Interest is : " + simpleInterest); sc.close(); } }
Output:

Also read – reverse string array in java