Java Program to Calculate Simple Interest

In this post, you will see how to write the java program to calculate the Simple Interest. Simple interest (SI) is based on the principal amount of a loan or the first deposit in a savings account. Simple interest doesn’t compound, which means a creditor will only pay interest on the principal amount and a borrower would never have to pay more interest on the previously accumulated interest.

Formula to calculate simple interest (SI),

Simple interest (SI) = ( P x T x R ) / 100

Here,
P is the principal amount 
T is the time and 
R is the rate

Example:
P= 1000, T= 5, R= 10
SI = (1000 x 5 x 10) / 100 => 50000 / 100 => 500.

Below is the java program logic to find simple interests,

package com.javacodepoint.basics;

import java.util.Scanner;

public class SimpleInterest {

	// main method
	public static void main(String[] args) {

		// Declare the required variables
		float principal, rate, time, si;

		// Scanner object to read inputs from user
		Scanner sc = new Scanner(System.in);

		// Reading inputs from user
		System.out.print("Enter the principal amount:: ");
		principal = sc.nextFloat();

		System.out.print("Enter the rate of interest:: ");
		rate = sc.nextFloat();

		System.out.print("Enter the time (in years):: ");
		time = sc.nextFloat();

		// Calculate the simple interest
		si = (principal * rate * time) / 100;

		// Print the result
		System.out.println("The simple interest:: " + si);
		System.out.println("Total amount to Pay (with interest):: " + (principal + si));

	}

}

OUTPUT:

Enter the principal amount:: 50000
Enter the rate of interest:: 8
Enter the time (in years):: 5
The simple interest:: 20000.0
Total amount to Pay (with interest):: 70000.0

See also: Java Program to Calculate Compound Interest.

Java logical programs list


Java Basic Programs

Java String Programs

Java Programs based on the Collection Framework

Leave a Reply

Your email address will not be published. Required fields are marked *