# Basic Java programming exercises

 Java Tutorial Java Exercises Data Structures

## Java program to calculate Simple Interest

Write a Java program to input principle, time and rate (P, T, R) from user and find Simple Interest. How to calculate simple interest in Java programming. Logic to find simple interest in Java program.

##### Required knowledge

Variables and expressions,Arithmetic operators,Basic input/output,Data types

##### Simple Interest formula

Simple interest formula is given by. Where,

P is the principle amount

T is the time and

R is the rate

##### Logic to calculate simple interest

Step by step descriptive logic to calculate simple interest.

1. Input principle amount in some variable say principle.

2. Input time in some variable say time.

3. Input rate in some variable say rate.

4. Find simple interest using formula SI = (principle * time * rate) / 100.

5. Finally, print the resultant value of SI.

##### Program to calculate simple interest
```/**
* Java program to calculate simple interest
*/

import java.util.Scanner;

class Test
{
public static void main(String args[])
{
float principle, time, rate, SI;
Scanner op=new Scanner(System.in);
/* Input principle, rate and time */
System.out.print("Enter principle (amount): ");
principle=op.nextFloat();

System.out.print("Enter time: ");
time=op.nextFloat();

System.out.print("Enter rate: ");
rate=op.nextFloat();

/* Calculate simple interest */
SI = (principle * time * rate) / 100;

/* Print the resultant value of SI */
System.out.println("Simple Interest = "+SI);

}
}
```

##### Output:

```Enter principle (amount): 5700
Enter time: 8
Enter rate: 2
Simple Interest = 912.0
```