0% found this document useful (0 votes)
10 views

Computer Science Assignment

The document contains 10 questions related to designing Visual Basic .NET forms and programs. Question 5 asks to create a form that accepts 4 subject marks as input, calculates the total and average, and displays the average. Question 6 asks to create a form that accepts a radius as input and calculates/displays the area and circumference of a circle. Question 7 asks to create a form that allows the user to select the shape and then displays the area of a square, circle, or rectangle based on the inputs.

Uploaded by

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

Computer Science Assignment

The document contains 10 questions related to designing Visual Basic .NET forms and programs. Question 5 asks to create a form that accepts 4 subject marks as input, calculates the total and average, and displays the average. Question 6 asks to create a form that accepts a radius as input and calculates/displays the area and circumference of a circle. Question 7 asks to create a form that allows the user to select the shape and then displays the area of a square, circle, or rectangle based on the inputs.

Uploaded by

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

Computer science assignment- 20CMS20

Q5) Enter 4 subjects marks, calculate the total and display the average

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim a As Integer
a = Val(TextBox1.Text) + Val(TextBox2.Text) + Val(TextBox3.Text) + Val(TextBox4.Text)
TextBox5.Text = a / 4
End Sub

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


TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()

End Sub
End Class

Q6) Form to find area and circumference of a circle

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim r As Integer
r = Val(TextBox1.Text)
TextBox2.Text = Math.PI * r * r
TextBox3.Text = 2 * Math.PI * r

End Sub

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


TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
End Sub
End Class

Q7. Design a form to find the area of square, circle and rectangle based on the user’s choice:

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Dim r As Decimal
r = Val(InputBox("Enter the radius", "CIRCLE"))
TextBox1.Text = Math.PI * r * r
End Sub

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


Dim s As Decimal
s = Val(InputBox("Enter the length of side", "SQUARE"))
TextBox1.Text = s * s
End Sub

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click


Dim l, b As Decimal
l = Val(InputBox("Enter the length", "RECTANGLE"))
b = Val(InputBox("Enter the breadth", "RECTANGLE"))
TextBox1.Text = l * b
End Sub
End Class
Q8) Prg to change background color using RGB form. [Default color set to purple]

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.BackColor = Color.FromArgb(233, 205, 208)
End Sub

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


Me.BackColor = Color.FromArgb(176, 224, 230)
End Sub

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click


Me.BackColor = Color.FromArgb(156, 175, 136)
End Sub
End Class

Q9) Prg to find the smallest of two numbers

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim a, b As Integer
a = Val(TextBox1.Text)
b = Val(TextBox2.Text)
If a < b Then
MessageBox.Show(a & " is the smallest number", "Information", MessageBoxButtons.OK)
Else
MessageBox.Show(b & " is the smallest number", "Information", MessageBoxButtons.OK)

End If
End Sub
End Class

Q10) Prg to accept 4 subject marks, calculate percentage and display final result as first class,
second class, pass class.

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim a As Decimal
a = Val(TextBox1.Text) + Val(TextBox2.Text) + Val(TextBox3.Text) + Val(TextBox4.Text)
TextBox5.Text = (a * 100) / 400
If Val(TextBox5.Text) >= 85 Then
MessageBox.Show("First class!", "Result", MessageBoxButtons.OK)
ElseIf Val(TextBox5.Text) < 85 And Val(TextBox5.Text) >= 70 Then
MessageBox.Show("second class!", "Result", MessageBoxButtons.OK)
ElseIf Val(TextBox5.Text) < 70 And Val(TextBox5.Text) >= 55 Then
MessageBox.Show("pass class!", "Result", MessageBoxButtons.OK)
Else
MessageBox.Show("fail!", "Result", MessageBoxButtons.OK)
End If
End Sub

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


TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()

End Sub
End Class

You might also like