Answer to Question #295457 in Visual Basic for Brenda

Question #295457

Exercise

 

25. Create an application that calculates a customer's water bill for the Canton Water Department. The user will enter the current meter reading and the previous meter reading. 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 $1.75 per 1000 gallons, or 0.00175 per gallon. However, there is a minimum charge of $19.50. In other words, every customer must pay at least $19.50. Display the total charge with a dollar sign and two decimal places. Use the following names for the solution and project, respectively: Canton Solution and Canton Project. Save the solution in the VbReloaded2015\Chap04 folder. Change the form file's name to Main Form.vb. Create the interface and then code the application. Save the solution and then start and test the application. Close the solution. (1-4)

Will try to send the pictures that go with this. This is the 2nd part of my question.


1
Expert's answer
2022-02-09T08:51:10-0500




Public Class Form1


    Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
        Dim previousMeterReading As Double = Double.Parse(txtPreviousMeterReading.Text)
        Dim currentMeterReading As Double = Double.Parse(txtCurrentMeterReading.Text)
        Dim gallonsWaterUsed As Double = currentMeterReading - previousMeterReading
        Dim totalChargeWater As Double = 19.5 + 0.00175 * gallonsWaterUsed
        txtGallonsWaterUsed.Text = gallonsWaterUsed.ToString("N")
        txtTotalChargeWater.Text = totalChargeWater.ToString("C")
    End Sub
End Class

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS