Can someone please help me in Visual Basic 2010! This question has been asked be
ID: 3556968 • Letter: C
Question
Can someone please help me in Visual Basic 2010!
This question has been asked before but the answers were not in Visual Basic.Net
A painting company has determined that for every 115 square feet or wall space, one gallon of paint and eight hours of labor will be required. The company charges $.18.00 per hour for labor . Write a program that allows the user to enter the number of rooms to be painted and the price of the paint per gallon. It should also ask for the square feet of wall space in each room. The program should have methods that return the following:
* The number of gallons of paint required
* The hours of labor required
*The cost of the paint
*The labor charges
*The Total cost of the paint job
Input validation: Do not accept a value less than 1 for the number of rooms. Do not accept a value less than $10.00 for the price of paint. Do accept a negative value for square footage of wall space.
Explanation / Answer
Public Class Form1
Const dblPAINT_HOURLY As Double = 18.0
Const dblHOURLY_NEEDED As Double = 8.0
Const dblPAINT_REQ As Double = 115.0
Dim dblTotalArea As Double
Dim dblPaintPerGal As Double = 0
Private Sub btnCalculate_Click(sender As System.Object, e As System.EventArgs) Handles btnCalculate.Click
Dim dblRooms As Double
Dim blnValidated As Boolean
Dim dblTotalArea As Double = 0
Validate_Input(dblRooms, dblPaintPerGal, blnValidated)
If blnValidated = True Then
dblTotalArea = CalcArea(dblRooms)
blnValidated = True
End If
MessageBox.Show("Area is: " & dblTotalArea)
End Sub
Private Sub btnExit_Click(sender As System.Object, e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Public Sub Validate_Input(ByRef dblRooms As Double, ByRef dblPaintPerGal As Double, ByRef blnValidated As Boolean)
If Double.TryParse(txtRooms.Text, dblRooms) Then
dblRooms = CDbl(txtRooms.Text)
blnValidated = True
Else
MessageBox.Show("Incorrect value, please use a number.", "Invalid Room Number")
txtRooms.Focus()
txtRooms.SelectAll()
blnValidated = False
Exit Sub
End If
If dblRooms <= 1 Then
MessageBox.Show("Number of rooms cannot be less than one.", "Invalid Room Number", MessageBoxButtons.OK, MessageBoxIcon.Error)
txtRooms.Focus()
blnValidated = False
Exit Sub
End If
If Double.TryParse(txtPaintGallons.Text, dblPaintPerGal) Then
dblPaintPerGal = CDbl(txtPaintGallons.Text)
blnValidated = True
Else
MessageBox.Show("Incorrect value, please use a number.", "Invalid Price of Paint")
txtPaintGallons.Focus()
txtPaintGallons.SelectAll()
blnValidated = False
Exit Sub
End If
If dblPaintPerGal <= 9.99 Then
MessageBox.Show("Price per gallon cannot be less than $10 dollars.", "Invalid Price of Paint", MessageBoxButtons.OK, MessageBoxIcon.Error)
txtPaintGallons.Focus()
blnValidated = False
Exit Sub
End If
End Sub
Public Function CalcArea(ByVal dblRooms As Double) As Double
Dim intCount As Integer
Dim dblArea As Double
Dim dblTotalArea As Double
For intCount = 1 To CInt(dblRooms)
dblArea = CDbl(InputBox("Enter area of room " & intCount))
dblTotalArea += dblArea
Next
Return dblTotalArea
Return dblRooms
End Function
Public Function CalcPaintReq(ByVal dblArea As Double) As Double
Dim dblPaintReq As Double = 0
Return dblArea / dblPAINT_REQ
End Function
Public Function CalcLabor(ByVal dblArea As Double) As Double
Return dblArea * dblPAINT_HOURLY
End Function
Public Function CalcHourReq(ByVal dblArea As Double) As Double
Return dblArea * dblHOURLY_NEEDED
End Function
Public Function CalcPaintCost(ByVal dblArea As Double) As Double
Return dblArea / (dblPAINT_REQ * dblPaintPerGal)
End Function
Public Function CalcTotalCharges(dblArea As Double) As Double
Return CalcPaintReq(dblArea) + CalcLabor(dblArea) + CalcHourReq(dblArea) + CalcPaintCost(dblArea)
End Function
End Class