Geekpedia Programming Tutorials






Simple Interest Calculator Java Applet

A sample interest calculator, very basic in functionality, coded in Java and ready to be compiled and executed as a Java Applet.

On Friday, July 31st 2009 at 08:30 PM
By Andrew Pociu (View Profile)
*****   (Rated 5 with 1 votes)
Contextual Ads
More Java Resources
Advertisement
  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import java.applet.*;
  4. import java.text.NumberFormat;
  5.  
  6. public class InterestCalculator extends Applet implements ActionListener
  7. {
  8.         TextField textPresentVal = new TextField("0", 10);
  9.         TextField textInterestRate = new TextField("0", 10);
  10.         TextField textPeriods = new TextField("0", 10);
  11.         Label lblPresentVal = new Label("Present Value");
  12.         Label lblInterestRate = new Label("Interest Rate");
  13.         Label lblPeriods = new Label("Number of Periods");
  14.         Label lblFutureVal = new Label("Future Value:");
  15.         Button btnOk = new Button("Calculate");
  16.  
  17.         public void init()
  18.         {
  19.  
  20.                 add(lblPresentVal);
  21.                 add(textPresentVal);
  22.                 add(lblInterestRate);
  23.                 add(textInterestRate);
  24.                 add(lblPeriods);
  25.                 add(textPeriods);
  26.                 add(lblFutureVal);
  27.                 add(btnOk);
  28.  
  29.                 btnOk.addActionListener(this);
  30.         }
  31.  
  32.         public void actionPerformed(ActionEvent evt)  
  33.         {
  34.             if (evt.getSource() == btnOk)
  35.             {
  36.                 int PresentVal = Integer.parseInt(textPresentVal.getText());
  37.                 int InterestRate = Integer.parseInt(textInterestRate.getText());
  38.                 int Periods = Integer.parseInt(textPeriods.getText());
  39.                 double FutureVal = PresentVal * (Math.pow((1 + InterestRate), Periods));
  40.                 NumberFormat nf = NumberFormat.getCurrencyInstance();
  41.                 lblTotal.setText("Future Value: " + nf.format(FutureVal));
  42.  
  43.                 repaint();
  44.             }
  45.         }
  46. }
Digg Digg It!     Del.icio.us Del.icio.us     Reddit Reddit     StumbleUpon StumbleIt     Newsvine Newsvine     Furl Furl     BlinkList BlinkList

Rate Rate this code snippet
Comment Current Comments
by dk on Thursday, October 8th 2009 at 07:20 AM

how to convert number to word in java script

by dk on Thursday, October 8th 2009 at 07:20 AM

how to convert number to word in java script

by dk on Thursday, October 8th 2009 at 07:20 AM

how to convert number to word in java script

by dk on Thursday, October 8th 2009 at 07:20 AM

how to convert number to word in java script

by dk on Thursday, October 8th 2009 at 07:20 AM

how to convert number to word in java script

by dk on Thursday, October 8th 2009 at 07:20 AM

how to convert number to word in java script

by Jayson on Sunday, October 11th 2009 at 06:22 AM

just put a number with "";
example:
"2"
it is now a string which is a word

by ponti on Wednesday, October 14th 2009 at 02:34 PM


Columns A B C D E F G
Rows 1 17573.87 8466.09 -150.52 173 0.06035773 12.4 6.0%
2 102800.94 69462.66 -957.02 180 0.078214284 7.75%
3 152833.13 109327.87 -1456.45 180 0.082185787 8.25%
4 8428.41 3240.75 -82.76 141 0.060365243 6.0%


Legend :
A - Current Principal Balance
B - Interest Paid Amount
C - Payment Amount
D - Payment Length

E - Computed Interest Rate ( Computed in excel using RATE() with parameters =RATE( D1,C1,A1 ) * F1
F - Contant Number of Months


I have a requirement to get the Interest Rate ( Column E ) using peoplecode in AE. In the above example
data 1-4 derives their Interest Rate ( Column E ) using Rate() in excel. Now I have to simulate it in code
but I can't come-up with a better code formula using vb that will generate the same results as above ( Column E ) they computed
in excel using Rate().

Any Idea?

by janice on Thursday, March 4th 2010 at 02:23 AM

well thought...


Comment Comment on this tutorial
Name: Email:
Message:
Comment Related Source Code
There is no related code.

Comment Related Tutorials
There are no related tutorials.

Jobs Java Job Search
My skills include:

Enter a City:

Select a State:


Advanced Search >>
Latest Tech Bargains

Advertisement

Free Magazine Subscriptions

Today's Pictures

Today's Video

Other Resources

Latest Download

Latest Icons