Join
Blogs
Questions
Videos
Tags
Members
Search
 
 
Create your own blog, earn points and get popular!

Simple Interest Calculation in Java

  1. /*
  2.  * Simple Interest Calculation in Java
  3.  */
  4. import java.io.*;
  5.  
  6. class SimpleInterestCalculation{
  7.  
  8.  public static void main(String s[]){
  9.  
  10.   float p=0f;
  11.   float r=0f;
  12.   int n=0;
  13.   float si = 0.0f;
  14.  
  15.   String s1;
  16.   DataInputStream d1 = new DataInputStream(System.in);
  17.  
  18.   try{
  19.    
  20.     System.out.print("Enter Principal Amount: ");
  21.    s1 = d1.readLine();
  22.    p = Float.valueOf(s1).floatValue();
  23.  
  24.     System.out.print("Enter Rate of Interest: ");
  25.    s1 = d1.readLine();
  26.    r = Float.valueOf(s1).floatValue();
  27.  
  28.     System.out.print("Enter Duration: ");
  29.    s1 = d1.readLine();
  30.    n = Integer.valueOf(s1).intValue();
  31.    
  32.   }catch(Exception e){
  33.    System.out.println("Invalid Number..." + e);
  34.    System.exit(0);
  35.   }
  36.  
  37.   si = (p * r * n)/100f;  
  38.   System.out.println("Simple Interest = " + si);
  39.  
  40.   }
  41. }
No votes yet
Share this
Anonymous's picture

thank you

thank you
Anonymous's picture

thank you

thank you

Post new comment

1 + 7 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.