Write a Java program to calculate Simple Interest

  • Estimate Completion Time
    not found 30 minutes
  • Difficulty Level:

Solution

import java.util.Scanner;
public class ClassName {
public static void main(String[] args) 
{
double principal;
double rate;
double time;

	Scanner sc = new Scanner(System.in);
	System.out.print("Enter the principal amount  ");
	principal = sc.nextDouble();
	System.out.print("Enter the rate of interest ");
	rate = sc.nextDouble();
	System.out.print("Enter the time ");
	time = sc.nextDouble();

	double interest = (principal * rate * time) / 100;
	System.out.println("The calculated Simple Interest is  " + interest);
}
}
Output
Enter the principal amount 75000
Enter the rate of interest 6.25
Enter the time 3

The calculated Simple Interest is 14062.5

Explanation

  • To calculate simple interest, three variables are declared – principal, rate, and time of data type “double”.
  • Scanner class is used to read the input from the user.
  • The object “sc” reads the input entered by the user using “nextDouble()” method and stored in the respective variable.
  • Calculate the simple interest formula and print the result in the console window using the Java print statement.
QA Ads Banner

Proleed Academy

Proleed serves / offers professionally designed IT training courses
globally.

Copyright © 2023 - Proleed Academy | All Rights Reserved.