Java Programming | Calculating simple interest.


This is a tutorial for calculating simple interest in java. The program is given below that take inputs and calculates the simple interest and prints it. The program is not extendable. Go enjoy the program. Lets begin……….

Program for calculating simple interest in java.

//import Scanner as we require it.
import java.util.Scanner;

// the name of our class its public
public class SimpleInterest {
	//void main
		public static void main (String[] args)
			//declare float
			float a,y,r,si,t;
			//define scanner
			Scanner input = new Scanner(;

			//print message and take input.
			System.out.println("Enter Amount:");
			 a = input.nextFloat();

			 System.out.println("Enter Years");
			 y = input.nextInt();

			 System.out.println("Enter Rate of interest");
		     r = input.nextFloat();


		     //print the output
			System.out.println("Simple interest = "+si);
			System.out.println("Total = " + t);


Enter Amount:
Enter Years
Enter Rate of interest
Simple interest = 60.0
Total = 1060.0

How it works

  1. The program prints the message to enter necessary inputs.
  2. The user enters inputs.
  3. Simple interest and total is calculated
  4. The SI and Total  is printed.

Extending it

The program cannot be extended. There are no direction in which you can extend. So you cannot extend the program.


  1. Import the Scanner.
  2. Declare the class as public
  3. Add the void main function
  4. Add system.out.println() function with the message to enter necessary inputs.
  5. Declare input as Scanner.
  6. Take the inputs and save it in variables.
  7. Calculate Si and Total and save it in other variable.
  8. Add system.out.println() function to print the calculated Si and Total.

At the end.

You learnt creating the Java program for Calculating Simple Interest. So now enjoy the program.

Please comment on the post and share it.
And like it if you liked.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s