A sample interest calculator, very basic in functionality, coded in Java and ready to be compiled and executed as a Java Applet.
import java.awt.*; import java.awt.event.*; import java.applet.*; import java.text.NumberFormat; public class InterestCalculator extends Applet implements ActionListener TextField textPresentVal = new TextField("0", 10); TextField textInterestRate = new TextField("0", 10); TextField textPeriods = new TextField("0", 10); Label lblPresentVal = new Label("Present Value"); Label lblInterestRate = new Label("Interest Rate"); Label lblPeriods = new Label("Number of Periods"); Label lblFutureVal = new Label("Future Value:"); Button btnOk = new Button("Calculate"); public void init() { add(lblPresentVal); add(textPresentVal); add(lblInterestRate); add(textInterestRate); add(lblPeriods); add(textPeriods); add(lblFutureVal); add(btnOk); btnOk.addActionListener(this); } public void actionPerformed(ActionEvent evt) { if (evt.getSource() == btnOk) { int PresentVal = Integer.parseInt(textPresentVal.getText()); int InterestRate = Integer.parseInt(textInterestRate.getText()); int Periods = Integer.parseInt(textPeriods.getText()); double FutureVal = PresentVal * (Math.pow((1 + InterestRate), Periods)); NumberFormat nf = NumberFormat.getCurrencyInstance(); lblTotal.setText("Future Value: " + nf.format(FutureVal)); repaint(); } } }