

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Program to Calculate Simple Interest
In this article, we will understand how to calculate the simple interest. Simple Interest is calculated using the following formula, If Principal = P, Rate = R% per annum, Time = T years:
Simple Interest (S.I) = P * T * R / 100
Simple Interest − The percentage interest on total principal amount. Returns are less compared to Compound Interest.
Below is a demonstration of the same −
Input
Suppose our input is −
Enter a Principle number : 100000 Enter a Interest rate : 5 Enter a Time period in years : 2
Output
The desired output would be −
Simple Interest : 1000
Algorithm
Step 1 – START Step 2 – Declare four float values principle, rate, time, simple_interest Step 3 – Read values of principle, rate, time, from the user Step 4 – Perform "(principle*rate*time)/100" to calculate the simple interest and store it in a simple_interest variable Step 8 – Display simple_interest Step 10 – STOP
Example 1
Here, the input is being entered by the user based on a prompt. You can try this example live in ourcoding ground tool .
import java.util.Scanner; public class SimpleInterest{ public static void main (String args[]){ float principle, rate, time, simple_interest; System.out.println("Required packages have been imported"); Scanner my_scanner = new Scanner(System.in); System.out.println("A my_scanner object has been defined "); System.out.print("Enter a Principle number : "); principle = my_scanner.nextInt(); System.out.print("Enter a Interest rate : "); rate = my_scanner.nextInt(); System.out.print("Enter a Time period in years : "); time = my_scanner.nextInt(); simple_interest = (principle*rate*time)/100; System.out.println("The Simple Interest is : " + simple_interest); } }
Output
Required packages have been imported A Scanner object has been defined Enter a Principle number : 10000 Enter a Interest rate : 5 Enter a Time period in years : 2 The Simple Interest is : 1000.0
Example 2
Here, the integer has been previously defined, and its value is accessed and displayed on the console.
public class SimplInterest{ public static void main (String args[]){ float principle, rate, time, simple_interest; principle = 100000; rate = 5; time = 2; System.out.printf("The Principle amount is %f \nThe interest rate is %f \nThe time period in years is %f " , principle, rate, time); simple_interest = (principle*rate*time)/100; System.out.println("\nThe Simple Interest is: " + simple_interest); } }
Output
The Principle amount is 100000.000000 The interest rate is 5.000000 nThe time period in years is 2.000000 The Simple Interest is: 1000.0
- Related Questions & Answers
- Java Program to calculate Simple Interest and Compound Interest
- Java Program to calculate Compound Interest
- Java Program to Calculate the Compound Interest
- C Program for simple interest?
- Python Program for simple interest
- Simple interest in Python Program
- Compare simple interest and compound interest.
- Python Program to Compute Simple Interest Given all the Required Values
- Golang Program to Compute Simple Interest Given all the Required Values
- Calculate compound interest in JavaScript
- Simple program of Java
- C++ program to calculate how many years needed to get X rupees with 1% interest
- Java program to calculate mode in Java
- Java program to calculate student grades
- Java program to calculate the percentage
Advertisements