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

Write a program to calculate simple interest for given amount, interest rate and duration

  1. /*
  2.  * Write a program to calculate simple interest for given amount, interest rate and duration.
  3.  * Program should take principal amount, duration and rate of interest using command line arguments.
  4.  *
  5.  */
  6. class SimpleInterest
  7. {
  8.  public static void main(String[] args){
  9.  
  10.   float principal ,rateOfInterest ,interest;
  11.   int noOfYears;
  12.  
  13.   principal = Float.valueOf(args[0]).floatValue();
  14.   noOfYears = Integer.parseInt(args[1]);
  15.   rateOfInterest = Float.valueOf(args[2]).floatValue();
  16.  
  17.   interest = (principal * rateOfInterest * noOfYears)/100;
  18.  
  19.   System.out.println("Interest is " + interest);
  20.  
  21.  }
  22. }
Your rating: None Average: 2.2 (5 votes)
Share this

Post new comment