Q:

Java program to calculate Simple Interest

0

Java program to calculate Simple Interest

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now