# solution

In this exercise, you create an application that allows the user to enter as many rainfall amounts as needed. The applicationâ€™s interface is shown in Figure 19-19. Each time the user enters a rainfall amount in the text box and then clicks the Add to Total button, the amount should be added to the total rainfall amount, which then should be displayed in the interface. In other words, the application should keep a running total of the rainfall amounts. When the user clicks the Calculate Average button, the buttonâ€™s Click event procedure should calculate and display the average rainfall amount. When the user clicks the Start Over button, the buttonâ€™s Click event procedure should reset the counter and accumulator variables to 0 and also clear the total and average rainfall amounts from the labels.

a. Create a Visual Basic Windows application. Use the following names for the solution and project, respectively: Rainfall Solution and Rainfall Project. Save the application in the ClearlyVB2012Chap19 folder. Change the name of the form file on your disk to frmMain.vb. If necessary, change the formâ€™s name to frmMain.

b. Create the interface shown in Figure 19-19. The text box should accept only numbers, the period, and the Backspace key. Display the average rainfall with two decimal places. Clear the Total rainfall and Average rainfall boxes when a change is made to the text box. Code the application.

c. Save the solution and then start the application. Enter 3.5 in the Rainfall amount box and then click the Add to Total button. The number 3.5 appears in the Total rainfall box. Change the entry in the Rainfall amount box to 2 and then click the Add to Total button. The number 5.5 appears in the Total rainfall box. Change the entry in the Rainfall amount box to 1.5 and then click the Add to Total button. The number 7.0 appears in the Total rainfall box. Change the entry in the Rainfall amount box to 4 and then click the Add to Total button. The number 11.0 appears in the Total rainfall box. Click the Calculate Average button. The number 2.75 appears in the Average rainfall box.

d. Click the Start Over button. Change the entry in the Rainfall amount box to 3 and then click the Add to Total button. The number 3 appears in the Total rainfall box. Click the Calculate Average button. The number 3.00 appears in the Average rainfall box. Close the Code Editor window and then close the solution.