0% found this document useful (0 votes)
4 views2 pages

VB NET Exercises

The document contains two VB.NET console program solutions. The first program classifies a student's age into categories such as Child, Teenager, Young Adult, and Adult based on user input. The second program implements a simple calculator that performs addition, subtraction, multiplication, and division based on user-selected operations.

Uploaded by

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

VB NET Exercises

The document contains two VB.NET console program solutions. The first program classifies a student's age into categories such as Child, Teenager, Young Adult, and Adult based on user input. The second program implements a simple calculator that performs addition, subtraction, multiplication, and division based on user-selected operations.

Uploaded by

chblaizo
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

VB.

NET Console Programs – Solutions

Question 1 – Student Age Classification

Write a program that asks the user to enter a student's age and displays the category.
Module Module1
Sub Main()
Dim age As Integer

[Link]("Enter student's age: ")


age = Convert.ToInt32([Link]())

If age < 13 Then


[Link]("Category: Child")
ElseIf age >= 13 And age <= 19 Then
[Link]("Category: Teenager")
ElseIf age >= 20 And age <= 35 Then
[Link]("Category: Young Adult")
Else
[Link]("Category: Adult")
End If

[Link]()
End Sub
End Module

Question 2 – Simple Calculator

Write a program that performs arithmetic operations using Select Case.


Module Module1
Sub Main()
Dim num1, num2, result As Double
Dim choice As Integer

[Link]("Enter first number: ")


num1 = [Link]([Link]())

[Link]("Enter second number: ")


num2 = [Link]([Link]())

[Link]("Choose operation:")
[Link]("1 - Addition")
[Link]("2 - Subtraction")
[Link]("3 - Multiplication")
[Link]("4 - Division")

[Link]("Enter your choice: ")


choice = Convert.ToInt32([Link]())

Select Case choice


Case 1
result = num1 + num2
[Link]("Result: " & result)

Case 2
result = num1 - num2
[Link]("Result: " & result)

Case 3
result = num1 * num2
[Link]("Result: " & result)

Case 4
If num2 <> 0 Then
result = num1 / num2
[Link]("Result: " & result)
Else
[Link]("Error: Cannot divide by zero")
End If

Case Else
[Link]("Invalid choice")
End Select

[Link]()
End Sub
End Module

You might also like