Java The Complete Reference, Seventh Edition

(Greg DeLong) #1

931


32


Financial Applets


and Servlets


D


espite all the large, sophisticated applications, such as word processors, databases,
and accounting packages, that dominate much of the computing landscape, there
has remained a class of programs that are both popular and small. These perform
various financial calculations, such as the regular payments on a loan, the future value
of an investment, or the remaining balance on a loan. None of these calculations are very
complicated or require much code, yet they yield information that is quite useful.
As you know, Java was initially designed to support the creation of small, portable
programs. Originally, these programs took the form of applets, but a few years later, servlets
were added. (Recall thatappletsrun on the local machine, inside the browser, andservlets
execute on the server.) Because of their small size, many of the common financial calculations
are right-sized for applets and servlets. Furthermore, including a financial applet/servlet in a
web page is an amenity that many users will appreciate. A user will return again and again to
a page that offers the calculation that he or she desires.
This chapter develops a number of applets that perform the financial calculations
shown here:



  • Regular payments on a loan

  • Remaining balance on a loan

  • Future value of an investment

  • Initial investment needed to attain a desired future value

  • Annuity from an investment

  • Investment necessary for a desired annuity


The chapter ends by showing how to convert the financial applets into servlets.

Free download pdf