# Chapter 63 Programming Exercises

## Exercise 1 — Ideal Weight Calculator

Write the application part of the ideal weight calculator that is described in this chapter (the first version). Use the approximate formula:

```W = H2 / 30 , for female

W = H2 / 28 , for male
```
where W is the ideal weight in pounds, H is the height in inches

For the height, use the middle of the range for each of the radio button's ranges. Set an action command for each radio button using `setActionCommand(String)` just as for push buttons. Add an action listener for each button using `addActionListener()`.

Pick initial settings of the buttons and when the program starts up display the ideal weight for those settings. Each time a new button is clicked calculate and display the new ideal weight. If you are actually interested in your ideal weight, search the Web for more accurate calculators.

## Exercise 2 — Ideal Weight with Glue

Finish the graphical interface code that uses glue to separate the two button panels. Experiment with adding more glue, perhaps to the left and right of the button panels, between the buttons, and between the button box and the result panel. Resize the display of the frame to see the effect of glue. Add the application code from exercise 1.