Here is a Java program to calculate the simple interest. In this java program to calculate simple interest, we first take amount, duration in year and rate of interest as input from user and use following equation to calculate simple interest.
Simple Interest = (Principle x Rate x Time) / 100
Java program to calculate simple interest
package com.tcc.java.programs; import java.util.Scanner; class SimpleInterest { public static void main(String[] args) { double principal, time, rate, SI; Scanner scanner = new Scanner(System.in); // Taking input from user System.out.println("Enter Amount"); principal = scanner.nextDouble(); System.out.println("Enter Duration in Years"); time = scanner.nextDouble(); System.out.println("Enter Rate of Interest"); rate = scanner.nextDouble(); // Calculate Simple Interest SI = (principal * time * rate) / 100; System.out.format("Simple Interest = %f", SI); } }Output
Enter Amount 10000 Enter Duration in Years 3 Enter Rate of Interest 10 Simple Interest = 3000.000000
Recommended Posts