Friday, January 28, 2011

Word Problem 2 - Mega Burgers in Visual Basic

Diane bought 7 Mega Burgers. Each Mega Burger cost $4. How many dollars did she spend on the Mega Burgers?

Write a program to display how much the Mega Burgers cost in Visual Basic.

 Public Class Form1  
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Declare variables
Dim MB, Cost, TotalPrice As Integer
'Set values
MB = 7
Cost = 4
TotalPrice = MB * Cost
'Display results
MessageBox.Show("The Mega Burgers cost " & FormatCurrency(TotalPrice))
End Sub
End Class

No comments:

Post a Comment