visual basic barcode program 9: Financial Applets and Servlets in Java

Encode PDF-417 2d barcode in Java 9: Financial Applets and Servlets

9: Financial Applets and Servlets
PDF417 Reader In Java
Using Barcode Control SDK for Java Control to generate, create, read, scan barcode image in Java applications.
PDF417 Printer In Java
Using Barcode encoder for Java Control to generate, create PDF417 image in Java applications.
// A simple loan calculator applet. import java.awt.*; import java.awt.event.*; import java.applet.*; import java.text.*; /* <applet code="RegPay" width=280 height=200> </applet> */ public class RegPay extends Applet implements ActionListener { TextField amountText, paymentText, periodText, rateText; Button doIt; double principal; // original princial double intRate; // interest rate double numYears; // length of loan in years /* Number of payments per year. You could allow this value to be set by the user. */ final int payPerYear = 12; NumberFormat nf; public void init() { // Use a grid bag layout. GridBagLayout gbag = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); setLayout(gbag); Label heading = new Label("Compute Monthly Loan Payments"); Label Label Label Label amountLab = new Label("Principal"); periodLab = new Label("Years"); rateLab = new Label("Interest Rate"); paymentLab = new Label("Monthly Payments");
PDF 417 Scanner In Java
Using Barcode scanner for Java Control to read, scan read, scan image in Java applications.
Barcode Creator In Java
Using Barcode generator for Java Control to generate, create bar code image in Java applications.
amountText = new TextField(16); periodText = new TextField(16); paymentText = new TextField(16); rateText = new TextField(16);
Bar Code Recognizer In Java
Using Barcode scanner for Java Control to read, scan read, scan image in Java applications.
Make PDF-417 2d Barcode In C#
Using Barcode maker for Visual Studio .NET Control to generate, create PDF417 image in Visual Studio .NET applications.
The Art of Java
Creating PDF 417 In VS .NET
Using Barcode drawer for ASP.NET Control to generate, create PDF 417 image in ASP.NET applications.
PDF417 Creation In VS .NET
Using Barcode creation for VS .NET Control to generate, create PDF-417 2d barcode image in .NET applications.
// Payment field for display only. paymentText.setEditable(false); doIt = new Button("Compute"); // Define the grid bag. gbc.weighty = 1.0; // use a row weight of 1 gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.anchor = GridBagConstraints.NORTH; gbag.setConstraints(heading, gbc); // Anchor most components to the right. gbc.anchor = GridBagConstraints.EAST; gbc.gridwidth = GridBagConstraints.RELATIVE; gbag.setConstraints(amountLab, gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; gbag.setConstraints(amountText, gbc); gbc.gridwidth = GridBagConstraints.RELATIVE; gbag.setConstraints(periodLab, gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; gbag.setConstraints(periodText, gbc); gbc.gridwidth = GridBagConstraints.RELATIVE; gbag.setConstraints(rateLab, gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; gbag.setConstraints(rateText, gbc); gbc.gridwidth = GridBagConstraints.RELATIVE; gbag.setConstraints(paymentLab, gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; gbag.setConstraints(paymentText, gbc); gbc.anchor = GridBagConstraints.CENTER; gbag.setConstraints(doIt, gbc); // Add all the components. add(heading); add(amountLab); add(amountText); add(periodLab); add(periodText); add(rateLab); add(rateText);
PDF417 Creation In VB.NET
Using Barcode encoder for .NET framework Control to generate, create PDF417 image in VS .NET applications.
Draw Data Matrix In Java
Using Barcode creator for Java Control to generate, create DataMatrix image in Java applications.
9: Financial Applets and Servlets
EAN 13 Printer In Java
Using Barcode maker for Java Control to generate, create GTIN - 13 image in Java applications.
Bar Code Generator In Java
Using Barcode maker for Java Control to generate, create barcode image in Java applications.
add(paymentLab); add(paymentText); add(doIt); // Register to receive action events. amountText.addActionListener(this); periodText.addActionListener(this); rateText.addActionListener(this); doIt.addActionListener(this); nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(2); nf.setMaximumFractionDigits(2); } /* User pressed Enter on a text field or pressed Compute. */ public void actionPerformed(ActionEvent ae) { repaint(); } // Display the result if all fields are completed. public void paint(Graphics g) { double result = 0.0; String amountStr = amountText.getText(); String periodStr = periodText.getText(); String rateStr = rateText.getText(); try { if(amountStr.length() != 0 && periodStr.length() != 0 && rateStr.length() != 0) { principal = Double.parseDouble(amountStr); numYears = Double.parseDouble(periodStr); intRate = Double.parseDouble(rateStr) / 100; result = compute(); paymentText.setText(nf.format(result)); } showStatus(""); // erase any previous error message
USPS Confirm Service Barcode Creation In Java
Using Barcode generation for Java Control to generate, create Planet image in Java applications.
GS1 - 13 Generation In Java
Using Barcode maker for Android Control to generate, create GTIN - 13 image in Android applications.
The Art of Java
Barcode Drawer In Objective-C
Using Barcode generation for iPhone Control to generate, create bar code image in iPhone applications.
Bar Code Generator In None
Using Barcode creation for Software Control to generate, create bar code image in Software applications.
} catch (NumberFormatException exc) { showStatus("Invalid Data"); paymentText.setText(""); } } // Compute the loan payment. double compute() { double numer; double denom; double b, e; numer = intRate * principal / payPerYear; e = -(payPerYear * numYears); b = (intRate / payPerYear) + 1.0; denom = 1.0 - Math.pow(b, e); return numer / denom; } }
Read UPC-A Supplement 2 In Java
Using Barcode decoder for Java Control to read, scan read, scan image in Java applications.
Code 128 Code Set C Creation In None
Using Barcode creator for Font Control to generate, create Code 128C image in Font applications.
The applet produced by this program is shown in Figure 9-1. To use the applet, simply enter the loan principal, the length of the loan in years, and the interest rate. The payments are assumed to be monthly. Once the information is entered, press Compute to calculate the monthly payment. The following sections examine the code to RegPay in detail. Because all the applets in this chapter use the same basic framework, much of the explanation presented here applies to the other applets presented in this chapter.
Scan Barcode In Java
Using Barcode reader for Java Control to read, scan read, scan image in Java applications.
Create EAN 13 In None
Using Barcode maker for Office Word Control to generate, create European Article Number 13 image in Word applications.
Figure 9-1
The RegPay applet
9: Financial Applets and Servlets
The RegPay Fields
RegPay begins by declaring a number of instance variables that hold references to the text fields into which the user will enter the loan information. Next, it declares the doIt variable that will hold a reference to the Compute button. RegPay then declares three double variables that hold the loan values. The original principal is stored in principal, the interest rate is stored in intRate, and the length of the loan in years is stored in numYears. These values are entered by the user through the text fields. Next, the final integer variable payPerYear is declared and initialized to 12. Thus, the number of payments per year is hard coded to monthly because this is the way that most loans are paid. As the comments suggest, you could allow the user to enter this value, but doing so will require another text field. The last instance variable declared by RegPay is nf, a reference to an object of type NumberFormat, which will describe the number format used for output.
Copyright © OnBarcode.com . All rights reserved.