Monday, January 31, 2011

Word Problem 6 - Quiz scores

a.) Given the table of quiz marks out of 25 in each subject calculate How many marks did Brian totally obtain in Mathematics and Science?
Write a program in Visual Basic to calculate the marks Brian obtained in Mathematics and Science.

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click  
'Declare variables
Dim M, S, marks As Integer
'Set values
M = 7 'Marks in Mathmetics
S = 22 'Marks in Science
marks = M + S
'Display results
MessageBox.Show("Brian has " & marks & " marks in Mathematics and Science.")
End Sub
End Class


b.) How many more marks does Andrew need for a perfect score in Mathematics?

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click  
'Declare variables
Dim M, S, marks As Integer
'Set values
M = 18 'Brian's actual marks
S = 25 'total possible
marks = S - M
'Display results
MessageBox.Show("Brian needs " & marks & " marks for a perfect score in Mathematics.")
End Sub
End Class


c.) What is Andrew's percentage for all of the quizzes together?

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click  
'Declare variables
Dim M, S, En, G As Integer
Dim marks As Decimal
'Set values
M = 18 'marks in Mathematics
S = 7 'marks in Science
En = 12 'marks in English
G = 15 'marks in Geography
marks = (S + M + En + G) / 100
'Display results
MessageBox.Show("Brian has " & FormatPercent(marks) & " marks for all the quizzes together.")
End Sub
End Class

No comments:

Post a Comment