This is problem 2PP from chapter 5, I followed the instructions outlined above b
ID: 3715357 • Letter: T
Question
This is problem 2PP from chapter 5, I followed the instructions outlined above but am still getting a few error codes. There is an eror in line 25 (calculate) which I can not seem to get past. Also, in line 25 there is an eror for total, not sure why as I declared it above. Then there is the output issue (error in lines 33-37) and in error in line 36 for formatting the currency, which is strange because it is fine in the other lines. Please help, thank you.
Restaurant Bill A fast-food vendor sells pizza slices ($1.75), fries ($2.00), and soft drinks ($1.25). Write a program to compute a customer's bill. The program should request the quantity of each item ordered in a Sub procedure, calculate the total cost with a Function procedure, and use a Sub procedure to display an itemized bill. A sample output is shown in Fig. 5.39 Restaurant Bill 1- How many pizza slices?3 Compute Total Cost How many fries?4 How many soft drinks? 5 ITEM pizza alices Eries oft drinks TOTAL QUANTITY PRICE $5.25 8.00 $6.25 $19.50 FIGURE 5.39 Possible outcome of Programming Project 2. Step-by-step solution Step 1 of 8 A program demonstrates that, quality of each item in a customer's bill, by calling the Sub procedures Create a new windows application project. In the Designer window, place textbox, label, group box, list box and button by using the related controls. Change the name of the textbox controls label controls and button then set the properties if required CommentExplanation / Answer
Public Class frmBill
Const PIZZA_PRICE As Double = 1.75
Const FRIES_PRICE As Double = 2
Const DRINKS_PRICE As Double = 1.25
Dim numberOfSlices As Integer = 0
Dim numberOfFries As Integer = 0
Dim numberOfDrinks As Integer = 0
Dim pizzaCost As Double = 0
Dim friesCost As Double = 0
Dim drinksCost As Double = 0
Dim total As Double = 0
Dim valid As Boolean = True
Private Sub btnCompute_Click(sender As Object, e As EventArgs) Handles btnCompute.Click
lstOutput.Items.Clear()
InputData()
total = TotalCost()
If valid = True Then
DisplayBill()
End If
End Sub
Sub InputData()
valid = True
If IsNumeric(txtPizza.Text) Then
If CInt(txtPizza.Text) >= 0 Then
numberOfSlices = CInt(txtPizza.Text)
Else
MessageBox.Show(“You entered a negative number. Please try again.”)
valid = False
End If
Else
MessageBox.Show(“You did not enter a numeric value. Please try again.”)
valid = False
End If
If IsNumeric(txtFries.Text) Then
If CInt(txtFries.Text) >= 0 Then
numberOfFries = CInt(txtFries.Text)
Else
MessageBox.Show(“You entered a negative number. Please try again.”)
valid = False
End If
Else
MessageBox.Show(“You did not enter a numeric value. Please try again.”)
valid = False
End If
If IsNumeric(txtDrinks.Text) Then
If CInt(txtDrinks.Text) >= 0 Then
numberOfDrinks = CInt(txtDrinks.Text)
Else
MessageBox.Show(“You entered a negative number. Please try again.”)
valid = False
End If
Else
MessageBox.Show(“You did not enter a numeric value. Please try again.”)
valid = False
End If
End Sub
Function TotalCost() As Double
pizzaCost = numberOfSlices * PIZZA_PRICE
friesCost = numberOfFries * FRIES_PRICE
drinksCost = numberOfDrinks * DRINKS_PRICE
Return pizzaCost + friesCost + drinksCost
End Function
Sub DisplayBill()
lstOutput.Items.Add(“ITEM QUANTITY PRICE”)
lstOutput.Items.Add(“pizza slices ” & numberOfSlices & ” ”& (pizzaCost).ToString(“C”))
lstOutput.Items.Add(“fries ” & numberOfFries & ” ” & (friesCost).ToString(“C”))
lstOutput.Items.Add(“soft drinks ” & numberOfDrinks & ” ”& (drinksCost).ToString(“C”))
lstOutput.Items.Add(“TOTAL ” & (total).ToString(“C”))
End Sub
End Class
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.