// A simple Applet to show how to use the AccountCmp class // Nancy McCracken 3/14/97 import java.awt.*; public class AccountCmpTest extends java.applet.Applet { Font f = new Font("TimesRoman", Font.BOLD, 24); AccountCmp paul; // variable for instance of Account class int x; // variables x and y control print placement int y; public void init() { // create a new instance of the Account class paul = new AccountCmp ("Paul", 5000.F ); } public void paint(Graphics g) { String s; g.setFont(f); x = 25; y = 25; print(g, "Paul's initial balance is $" + paul.getbalance()); // call an AccountCmp method on the instance paul paul.deposit(1500.F); print(g, "Paul deposits $1500."); s = paul.withdraw(523.F); print(g, "Paul withdraws $523."); paul.monthactivity(); print(g, "After one month, Paul's account has $" + paul.getbalance()); } public void print(Graphics g, String s) { g.drawString (s, x, y); y += 30; } }