0% found this document useful (0 votes)
20 views8 pages

Lab Ex 2

The document describes a programming assignment to create a student grade calculation application. It includes: 1) Designing a user interface to input a student's name and three test scores. 2) Creating a Student class with properties for the data and a method to calculate the average score. 3) Adding validation to ensure scores are between 0-100 in the Student class. 4) Saving, running and testing the application.

Uploaded by

2023103475
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views8 pages

Lab Ex 2

The document describes a programming assignment to create a student grade calculation application. It includes: 1) Designing a user interface to input a student's name and three test scores. 2) Creating a Student class with properties for the data and a method to calculate the average score. 3) Adding validation to ensure scores are between 0-100 in the Student class. 4) Saving, running and testing the application.

Uploaded by

2023103475
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 8

Name: Muhammad Abrar bin Zulkhurnain (17DDT18F1001)

Nuzul Furqan bin Rusman (17DDT18F1035)

Class: DDT4A

QUESTION 1:

Nokiah Samson, a professor at MayDreamzComeTrue College, wants an


application that allows her to enter each student’s name and three test scores.
The application should calculate and display each students average test score.

a. Design your application at the designer window.


b. Add a class file to the project and name the class file Student.vb. The Student
class should contain four properties. The MayDreamzComeTrue application will
use the class to create a Student object. It will store the user input in the object’s
properties, and use the object’s method to initialize the Private variables and
calculate and return the average test score.
c. In the class also include method named ValidateScores. The ValidateScores
method will verify that each test score is greater than or equal to a minimum
value, but less than or equal to maximum value. The minimum and maximum
values will be passed to the method by the procedure that invokes the method.
(Minimum value will be zero and maximum value will be 100).
d. Save, start and test your application.

(15 Marks)
Answer:

Interface design:
MyStudent Class:

Public Class MyStudent


Private test1 As Decimal
Private test2 As Decimal
Private test3 As Decimal
Private jaw As Decimal
Public Sub ValidateScores(ByVal No1 As Integer, ByVal No2 As Integer, ByVal
No3 As Integer)
If (No1 > 0 And No1 <= 100) And (No2 > 0 And No2 <= 100) And (No3 > 0 And
No3 <= 100) Then
test1 = No1
test2 = No2
test3 = No3
CalcAverage()
Else
MsgBox("Please enter a value from 0 to 100")
End If
End Sub
Function getJaw() As Decimal
Return jaw
End Function
Public Sub CalcAverage()
jaw = (test1 + test2 + test3) / 3
End Sub
End Class
Form1 :

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
Dim calculate As New MyStudent
calculate.ValidateScores(TextBox1.Text, TextBox2.Text, TextBox3.Text)

Label6.Text = calculate.getJaw

End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles


Button2.Click
TextBox1.Text = " "
TextBox2.Text = " "
TextBox3.Text = " "
Label6.Text = " "

End Sub
End Class
My Interface after run:
Entering the correct data:
Entering the incorrect data:
Reset Button:

You might also like