programming Visual Basic Create an app to calculate the cost of a night of bowli
ID: 3735943 • Letter: P
Question
programming Visual Basic
Create an app to calculate the cost of a night of bowling including snacks. Check that the user enters a numeric value and if not, display an error message. The fees are as follow:
1) Cost per game is $5.00 2) Cost for shoe rental is a flat fee of $2.50 3) Cost for chips is $1.00 4) Cost for soda is $1.00 5) Cost for pizza is $2.00
if a bowler has a coupon, there is a $2.00 discount on the total cost. Make sure to code a Clear and Close function.
Make sure your app includes all the specifications on page one (listed with the point value for each item)
Explanation / Answer
Private Sub Command1_Click()
Dim cpg As Double, shr As Double, chp As Double, sd As Double, pz As Double
Dim total As Double,cp as Double
cpg = CInt(Text1.Text) * 5
shr = CInt(Text2.Text) * 2.5
chp = CInt(Text3.Text) * 1
sd = CInt(Text4.Text) * 1
pz = CInt(Text5.Text) * 2
If Text6.Text = "" Then
cp = 0
Else
cp = 2
End If
total = (cpg + shr + chp + sd + pz) - cp
Label1.Caption "Total Cost", CStr(total)
End Sub
Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
End Sub
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.