Java Programming : Simple Interest

Example
Input
enter the principal 1200
enter the rate 5
enter the time 2
Output
The simple interest is 120.0
Required to know
Use of Variables, Use of different operators like assignment or arithmetic operators, Use of functions like System. out.print(), and Use of Data types.
Formula
Simple interest = (principal * rate * timne) / 100
Steps
Take principal, rate and time as input from the user.
Use the formula to find the simple interest.
Print the value after calculating the simple interest.
Program
import java.util.Scanner;
public class simple {
/**
* This class calculates the simple interest.
*/
public static void main(String[] args) {
// Create a Scanner object to read user input.
Scanner sc = new Scanner(System.in);
// Prompt the user to enter the principal, rate and time.
System.out.print("Enter the principal: ");
double principal = sc.nextDouble();
System.out.print("Enter the rate of interest: ");
double rate = sc.nextDouble();
System.out.print("Enter the time period: ");
double time = sc.nextDouble();
// Calculate the simple interest.
double si = (principal * rate * time) / 100;
// Print the simple interest.
System.out.println("The simple interest is " + si);
}
}

