Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'Declare variables
Dim intCows, intSheep, intTotal As Integer
'Set values
intCows = 6
intSheep = 7
intTotal = C + S
'Display results
MessageBox.Show("Morgan has " & intTotal & " stuffed animals.")
End Sub
End Class
2.)Diane bought 7 mega burgers. Each mega burger cost $4. How many dollars did she spend on the mega burgers?
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Declare variables
Dim intMegaBurgers As Integer
Dim decCost, decTotalPrice As Decimal
'Set values
intMegaBurgers = 7
decCost = 4
decTotalPrice = intMegaBurgers * decCost
'Display results
MessageBox.Show("The Mega Burgers cost " & FormatCurrency(decTotalPrice))
End Sub
End Class
3.)Ole has 15 apples and 12 oranges. How many pieces of fruit does he have?
-Hard code the initial facts
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Declare variables
Dim intApples, intOranges, intFruit As Integer
'Set values
intApples = 15
intOranges = 12
intFruit = intApples + intOranges
'Display results
MessageBox.Show("Ole has " & intfFruit & " pieces of fruit.")
End Sub
End Class
4.)There are 33 horses in a field. 15 horses go into the barn. Then 7 of them come back out. How many horses are standing in the field?
-Hard code the initial values
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Declare variables
Dim intField, intBarn, intOut, intTotalHorses As Integer
'Set values
intField = 33
intBarn = 15
intOut = 7
intTotalHorses = intField - intBarn + intOut
'Display results
MessageBox.Show("There are " & intTotalHorses & " horses in the field.")
End Sub
End Class
5.)Inglebert has 15 apples and 3 times as many oranges. How many pieces of fruit does she have?
-Hard code the initial facts
Private Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Declare variables
Dim intApples, intOranges, intPiecesFruit As Integer
'Set values
intApples = 15
intOranges = intApples * 3
intPiecesFruit = intApples + intOranges
'Display results
MessageBox.Show("Inglebert has " & intPiecesFruit & " pieces of fruit.")
End Sub
End Class
6.)Don't make this table. This is just for your reference
English Geography Mathematics Science
Andrew 12 19 18 7
Brian 22 15 7 22
The table shows quiz marks out of 25 in each subject.
-How many marks did Brian totally obtain in Mathematics and Science?
Private Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Declare variables
Dim intMath, intScience, intMarks As Integer
'Set values
intMarks = 7 'Marks in Mathmetics
intScience = 22 'Marks in Science
intMarks = M + S
'Display results
MessageBox.Show("Brian has " & intMarks & " marks in Mathematics and Science.")
End Sub
End Class
-How many more marks does Andrew need for a perfect score in Mathematics? Private Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Declare variables
Dim intMath, intScience, intMarks As Integer
'Set values
intMath = 18 'Brian's actual marks
intScience = 25 'total possible
intMarks = intScience - intMath
'Display results
MessageBox.Show("Brian needs " & intMarks & " marks for a perfect score in Mathematics.")
End Sub
End Class
-What is Andrew's percentage for all of the quizzes together? Private Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Declare variables
Dim intEnglish, intGeography, intMath, intScience As Integer
Dim decMarks As Decimal
'Set values
intEnglish = 12 'marks in English
intGeography = 15 'marks in Geography
intMath = 18 'marks in Mathematics
intScience = 7 'marks in Science
decMarks = (intScience + intMath + intEnglish + intGeography) / 100
'Display results
MessageBox.Show("Brian has " & FormatPercent(decMarks) & " marks for all the quizzes together.")
End Sub
End Class
No comments:
Post a Comment