import java.awt.*;
import java.awt.event.*;

public class Example extends Frame implements WindowListener {
    private TextField result;
    private Cost dress = new Cost(45, 95);
    private Cost book = new Cost(15, 50);

    public static void main(String [] args) {
        Example ex = new Example();
        ex.setSize(400,200);
        ex.setVisible(true);
    } // main

    public Example() {
        super("Example");
        // Frame defaults to BorderLayout
        setLayout(new FlowLayout());
        result = new TextField(20);
        add(result);
        this.addWindowListener(this);
        dress.add(5, 0);
        book.add(3, 15);
        result.setText("Cost of book is $" + book.getDollars()
                        + "." + book.getContents());
    } // constructor

    public void windowClosing(WindowEvent e) {
        System.exit(0);
    } // windowClosing

    public void windowOpened(WindowEvent e) {}
    public void windowClosed(WindowEvent e) {}
    public void windowIconified(WindowEvent e) {}
    public void windowDeiconified(WindowEvent e) {}
    public void windowActivated(WindowEvent e) {}
    public void windowDeactivated(WindowEvent e) {}
} // Example

class Cost {
    private  int cents, dollars;

    public Cost(int d, int c) {
        dollars = d; cents = c;
    } // constructor

    public void add(int d, int c) {
        cents += c;
        if (cents > 100) {
            dollars += d + cents / 100;
            cents = cents % 100;
        }
        else
            dollars += d;
    } // add

    public int getDollars() {
        return dollars;
    } // getDollars

    public int getCents() {
        return cents;
    } // getCents

} // Cost