Question: I'm Having a problem with my solution, any help would be appreciated. A fast-food vendor sells pizza slices ($1.75), fries ($2.00), and soft drinks ($1.25).
I'm Having a problem with my solution, any help would be appreciated.
A fast-food vendor sells pizza slices ($1.75), fries ($2.00), and soft drinks ($1.25). Write a program to compute a customers 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.
Now I have the code, but the Fries and the Soft Drinks are inverse of each other.
My Code is
Public Class Form1 Private Sub BtnCompute_Click(sender As Object, e As EventArgs) Handles BtnCompute.Click
Dim Slices, Fries, Drinks As Double Dim PizzaSlices, DecFries, SoftDrinks, Total As Double InputData(Slices, Fries, Drinks) Calculate(Slices, Fries, Drinks, PizzaSlices, DecFries, SoftDrinks, Total) DisplayData(Slices, Fries, Drinks, PizzaSlices, DecFries, SoftDrinks, Total) End Sub
Sub InPutData(ByRef Slices As Double, ByRef Fries As Double, ByRef Drinks As Double) Slices = CDbl(TxtSlices.Text) Fries = CDbl(TxtFries.Text) Drinks = CDbl(TxtDrinks.Text) End Sub
Function Calculate(ByVal Slices As Double, ByVal Drinks As Double, ByVal Fries As Double, ByRef PizzaSlices As Double, ByRef DecFries As Double, ByRef SoftDrinks As Double, ByRef Total As Double) PizzaSlices = Slices * (1.75) DecFries = Fries * (2.0) SoftDrinks = Drinks * (1.25) Total = PizzaSlices + DecFries + SoftDrinks Return Total End Function
Sub DisplayData(ByVal Slices As Double, ByVal Drinks As Double, ByVal Fries As Double, ByRef PizzaSlices As Double, ByRef DecFries As Double, ByRef SoftDrinks As Double, ByRef Total As Double) FastMenu.Items.Add("ITEM " & " " & "QUANTITY " & " " & "PRICE ") FastMenu.Items.Add("Pizza Slices" & " " & Slices & " " & FormatCurrency(PizzaSlices)) FastMenu.Items.Add("Fries" & " " & Fries & " " & FormatCurrency(DecFries)) FastMenu.Items.Add("Soft Drinks" & " " & Drinks & " " & FormatCurrency(SoftDrinks)) FastMenu.Items.Add("Total" & " " & FormatCurrency(Total))
End Sub End Class
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
