Clearly Visual Basic Chapter 16 Exercise 9 Water Bill Solution
In this exercise, you code an application that calculates a water bill. The clerk at the water department will enter the current meter reading and the previous meter reading in two text boxes. The application should calculate and display the number of gallons of water used and the total charge for the water. The charge for water is $2.05 per 1000 gallons, or .00205 per gallon. Use two independent Sub procedures: one to make the calculations and the other to display the results. Call both Sub procedures from the Calculate button’s Click event procedure. Make the calculations only when the current meter reading is greater than or equal to the previous meter reading; otherwise, display an appropriate message in a message box.
a. List the output and input items, as well as any processing items, and then create an appropriate algorithm using pseudocode.
b. Create a Visual Basic Windows application. Use the following names for the solution and project, respectively: Water Bill Solution and Water Bill Project. Save the application in the ClearlyVB2010\Chap16 folder. Change the name of the form file on your disk to frmMain.vb. If necessary, change the form’s name to frmMain.
c. Create the interface shown in Figure 16-24 and then code the application. Be sure to code each text box’s KeyPress and TextChanged event procedures. Save the solution and then start and test the application. Close the Code Editor window and then close the solution.