Water Billing

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 1000gallons, 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. Add a button between the Calculate and Exit buttons, with the text “Clear”, and code it to clear the two input text boxes and the output labels. d. Put brief comments in all sub procedures, explaining what that section does: the button click procedure, the sub procedure for making the calculations, the sub procedure for displaying the results, as well as the Clear button and the Exit button sub procedures. e. Declare the rate of .00205 dollars per gallon as a constant. f. The variables for Current reading, Previous reading and Gallons used should be integers. g. Your message box for invalid input should include these things: i. The message should include the numbers the user entered, for example: “ERROR: Current reading (2000) cannot be less than Previous reading (3000).” ii. The title bar text should say “Invalid Input”. iii. The message box button should say “OK”. iv. The message box icon should be the Error icon. h. The output for the total charge should be displayed in currency format.

×
New Download