Privacy Policy Terms Of Use. Copyright © 2006-2010 Java Tutorials and Examples.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
- /*
- * Simple Interest Calculation in Java
- */
- import java.io.*;
- class SimpleInterestCalculation{
- public static void main(String s[]){
- float p=0f;
- float r=0f;
- int n=0;
- float si = 0.0f;
- String s1;
- DataInputStream d1 = new DataInputStream(System.in);
- try{
- System.out.print("Enter Principal Amount: ");
- s1 = d1.readLine();
- p = Float.valueOf(s1).floatValue();
- System.out.print("Enter Rate of Interest: ");
- s1 = d1.readLine();
- r = Float.valueOf(s1).floatValue();
- System.out.print("Enter Duration: ");
- s1 = d1.readLine();
- n = Integer.valueOf(s1).intValue();
- }catch(Exception e){
- System.out.println("Invalid Number..." + e);
- System.exit(0);
- }
- si = (p * r * n)/100f;
- System.out.println("Simple Interest = " + si);
- }
- }

thank you
thank you
Post new comment