Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using Variables and Constants in visual basics 2012 – Chapter 4C Exercise 10 Pro

ID: 3684102 • Letter: U

Question

Using Variables and Constants in visual basics 2012 – Chapter 4C Exercise 10

Program Requirements

The application allows the user to enter the current and previous meter readings

• The application should ask the user if this represents an agricultural account o Use message box to capture a yes or no reply

• The application should calculate and display the number of gallons of water used ant the total charge for the water

• The charge for water is $1.50 per 1000 gallons (0.0015/gallon) for agricultural customer, and $1.75 per 1000 gallons (0.00175/gallon) for all other customers

• There is a minimum charge of $16.67 (In other words, every customer must pay at least $16.67) • Display the total charge with a dollar sign and two decimal places

• The user should only be allowed to enter digits or the backspace key in the text boxes to Create one event procedure for both text boxes

• Clear the number of gallons used and the total charge when a change is made to the contents of a text box on the form to Create one event procedure for both text boxes

• When the text box receives the focus, select its existing text.

~The Calculate button should calculate the correct number of gallons used and the Total charge a. ~Use TryParse to convert the number of gallons entered to a number

~Use a message box to ask if the customer is an agricultural account a. No should be the default button

~Restrict the data entry of the textboxes to only numbers 0 – 9 and the backspace key When a textbox has the focus,

~select any entered text Clear the calculated amounts when a change is made to either text box

~Include the three Option statements

~Test your application using a total of 9000, 11000, and 15000 gallons used for both agricultural and non-agricultural customers

Pseudocode for Calculate button

1. Convert input to numbers

2. Calculate the number of gallons used

3. Determine if the customer is an agricultural account

4. Calculate the total charges

5. Display calculated amounts

6. Set focus to the Current Reading text box

Explanation / Answer

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim nogal, pre, cur As Integer
Dim totamt As Double
pre = Val(TextBox1.Text)
cur = Val(TextBox2.Text)
nogal = cur - pre

MsgBox("Total Gallons used" & nogal)

Dim result = MsgBox("Agriculture Account used?", MsgBoxStyle.YesNo)
If result = DialogResult.Yes Then
totamt = nogal * 0.0015
ElseIf result = DialogResult.No Then
totamt = nogal * 0.00175
End If
Label1.Text = "$" & totamt
TextBox2.Focus()
End Sub
End Class

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote