Simple interest is a method of calculating the interest charge on a loan in banking and economic sectors.
It gets estimated day to day with help of interest rate, principal amount and time.
- First we create scanner class object to pass input data from user.
- Integer.parseInt() method convert String data to Integer value.
- Here we convert principal, time and rate into integer.
- Now use the Simple Interest formula to calculate the rate.
- Print the Simple Interest data.
Simple interest formula is :-
Simple Interest = (P x T x R)/100
Here P = principal amount, R = Rate, T = Time (years)
import java.util.Scanner;
public class SimpleIntrest {
public static void main(String[] args) {
int principal, time, rate, SimpleInterest;
Scanner sc = new Scanner(System.in);
System.out.println("enter principal,time and rate.....");
principal = Integer.parseInt(sc.next());
time = Integer.parseInt(sc.next());
rate = Integer.parseInt(sc.next());
SimpleInterest = (principal * time * rate) / 100;
System.out.println("Simple Intrest is..........: " + SimpleInterest);
}
}
Output :-
enter principal,time and rate…..
1200
4
2
Simple Intrest is……….: 96