Here, you will learn how to calculate the Simple Interest in Java using the Formula ((p * r * t) / 100)) where,
- p = Principal
- r = Rate of Interest
- t = Time Period
The program takes the user input for Principal, Rate, and Time, calculates the result, and displays the result on the screen.
If you do not know about the operators or Data Types in java, click the link below to learn about operators as this program is using one.
Java Program to Calculate the Simple Interest
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | //Simple Interest in Java import java.util.Scanner; public class SimpleInterestJava { public static void main(String args[]) { float p, r, t, SI; Scanner scan = new Scanner(System.in); System.out.print("Enter the value for Principal: "); p = scan.nextFloat(); System.out.print("Enter the value for Rate of interest: "); r = scan.nextFloat(); System.out.print("Enter the value for Time period: "); t = scan.nextFloat(); scan.close(); SI = (p * r * t) / 100; System.out.print("Simple Interest is: " +SI); } } |
Output:
Enter the value for Principal: 1000
Enter the value for Rate of interest: 5
Enter the value for Time period: 2
Simple Interest is: 100.0
The above source code to calculate the Simple Interest in Java is compiled and ran successfully on a windows system. Browse through Java Program to learn more.