×

Java Programs

Java Practice

Java program to calculate Simple Interest

Simple Interest in Java - This program will read Principal, Rate and Time from the user and calculate the Simple Interest.

Simple Interest using Java Program

//Java program to calculate Simple Interest.
import java.util.*;
 
public class SimpleInterest{
 
    public static void main(String []args)
    {
        double p=0,r=0,t=0,si=0;
         
        //Scanner class to take user input.
        Scanner X = new Scanner(System.in);
         
        System.out.print("Enter Principle : ");
        p = X.nextFloat();
         
        System.out.print("Enter Rate of Interest: ");
        r =  X.nextFloat();
         
        System.out.print("Enter Time in years : ");
        t =  X.nextFloat();
         
        //Formula of simple interest.
        si = (p*r*t)/100;
         
        System.out.print("Simple Interest is :"+si+"\n");
                 
    }
}

Output

    me@linux:~$ javac SimpleInterest.java 
    me@linux:~$ java SimpleInterest 

    Enter Principle : 10000
    Enter Rate of Interest: 10
    Enter Time in years : 1
    Simple Interest is :1000

Core Java Example Programs »



Related Programs



Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.