Sunday, January 30, 2011

VB Word Problems

1. Morgan has 6 cows and 7 sheep. How many total animals does she have?
Public Class frmcows
   Private Sub btnAnwser_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAnwser.Click
  
     Dim sheep As Integer = 7
  
     Dim cows As Integer = 6
  
     Dim total As Integer
  
     total = sheep * cows
  
     MessageBox.Show(total)
  
   End Sub
  
 End Class
  

2. Diane bought 7 burgers, each of which cost $4. How much did she spend on burgers?
   Private Sub btnCost_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCost.Click
  
     Dim cost As Integer = 4
  
     Dim amount As Integer = 7
  
     Dim totalcost As Integer
  
     totalcost = cost * amount
  
     MessageBox.Show(totalcost)
  
   End Sub
  
 End Class
  

3. Ole has 15 apples and 12 oranges. Whats his total fruit count?
Public Class frmFruit
 Private Sub btnFruit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFruit.Click
  
     Dim apples As Integer = 15
  
     Dim oranges As Integer = 12
  
     Dim totalfruit As Integer
  
     totalfruit = apples + oranges
  
     MessageBox.Show(totalfruit)
  
   End Sub
  
 End Class
  

4. There are 33 horses to begin, 15 go into the barn, 7 come back out. What is the new population?

 Public Class frmHorses
  
   Private Sub btnLeftover_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLeftover.Click
  
     Dim beginningpopulation As Integer = 33
  
     Dim barn As Integer = 15
  
     Dim returners As Integer = 7
  
     Dim newpopulation As Integer
  
     newpopulation = beginningpopulation - barn + returners
  
     MessageBox.Show(newpopulation)
  
   End Sub
  
 End Class  

5. Ingelbert has 15 apples and 3 times as many oranges. How many pieces of fruit do they have?
 Public Class frmFruit2
  
   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  
     Dim apples As Integer = 15
  
     Dim oranges As Integer
  
     Dim total As Integer
  
     oranges = apples * 3
  
     total = apples + oranges
  
     MessageBox.Show(total)
  
   End Sub
  
 End Class  

6. Using the grade table decide how many marks did Brian score in math and science combined, how many more does Andrew need for a perfect math score, and what is Andrew's percentages for all o the quizzes put together.
 Public Class frmGradeTABLE
  
   Private Sub btnGradeInfo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGradeInfo.Click
  
     Dim AEnglish As Integer = 12
  
     Dim AGeography As Integer = 19
  
     Dim AMath As Integer = 18
  
     Dim AScience As Integer = 7
  
     Dim BEnglish As Integer = 22
  
     Dim BGeography As Integer = 15
  
     Dim BMath As Integer = 7
  
     Dim BScience As Integer = 22
  
     Dim combinedmath As Integer
  
     Dim mathperfectscore As Integer
  
     Dim APercentage As Integer
  
     Dim totalanwser As String
  
     combinedmath = BMath + AMath
  
     mathperfectscore = 25 - AMath
  
     APercentage = (AEnglish + AGeography + AMath + AScience) / 100
  
     totalanwser = String.Concat(combinedmath.ToString & Environment.NewLine, mathperfectscore.ToString & Environment.NewLine, APercentage.ToString & Environment.NewLine)
  
     Console.WriteLine(totalanwser)
  
     MessageBox.Show(totalanwser)
  
   End Sub
  
 End Class  

No comments:

Post a Comment