Simple interest
Simple interest is a simple way to calculate the interest on a loan. Simple interest is determined by multiplying the principal by the daily interest rate multiplied by the number of days elapsed between payments. – Investopedia
Logic
After taking input (Principle, Rate, Time) from the user we have to use a very simple formula shown below:
Simple interest formula
Where, P = Principle, T = Time and R = Rate
To calculate simple interest we have to multiply principal, rate and time, then divide it by 100 and print the result.
Program
import java.util.Scanner; public class SimpleInterest { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("Enter principal : "); float principal = scanner.nextFloat(); System.out.println("Enter rate : "); float rate = scanner.nextFloat(); System.out.println("Enter time : "); float time = scanner.nextFloat(); // Calculate simple interest double result = (principal * rate * time) / 100; System.out.println("Simple interest : " + result); } }
Output
Enter principal : 1000
Enter rate : 4
Enter time (year) : 2
Simple interest : 80.0