Cay Horstmann & Timothy Budd

Laboratory Notebook
Chapter 27 - Graphical User Interfaces

Your name:
Your email address:
Your student ID number:

Once this form has been customized for your institution, you can use this button to send your lab work. Be sure to read the instructions before starting your work.

Lab Objectives

To gain experience with

R1. Configuring Your Environment

If the computer which you are using for this lab is managed by your school, you probably already have the wxWindows toolkit installed and configured to compile wxWindows programs using your C++ compiler. However, if you are using your own computer, you will need to download wxWindows from The companion website for the text,, contains detailed instructions on how to compile wxWindows programs on your platform.

P1. Creating a Frame and Text Control

You will develop a GUI program in this lab which will ask the user to input the amount of a deposit to a cd, the number of years or term of the CD and the interest rate. Your program will then print out the value of the deposit at the end of the term. To begin , write the code to create a frame.

Now, add a text control to the frame.

P2. Layout Management

The user interface for the CD Calculator application should look similar to the following:

Notice that there are four textboxes, two buttons and several labels. We have already designed the frame and a text control.
The top line can be displayed as a single wxStaticText object. The labels and text controls should be displayed using a wxFlexGridSizer to create two columns.
Modify your code from P1 to display the top line (Certificate of Deposit Calculator) as well as all of the labels and text controls.

P3. Buttons and Actions

Next, add the two buttons. These are added by creating new objects of the wxButton class.

We need to define actions for each button using an event table. The onClearForm event should simply clear out all of the text controls. The onCalculate event should do the following:

Add the event table to your code as well as the appropriate methods to the buttonframe.

Use the following test data to determine if your application is working properly:

Deposit Interest Rate Number Of Years Final Value
120000 .09 10 294162.84
10000 .05 2 11049.41
34555 .1 15 153905.19

Do not forget to send your answers when you are finished.