Home >>VB.Net Programs >VB.Net program to find the division of a student based on a given percentage
Here, we can read the percentage of a student from the user and then print the student division on the console screen using the if statement.
Program :
The source code for finding out the student division based on the percentage given is given below. The program given is compiled and successfully executed.
Example
Module Module1
Sub Main()
Dim percentage As Double = 0
Console.Write("Enter percentage: ")
percentage = Double.Parse(Console.ReadLine())
If percentage > 60 Then
Console.WriteLine("First division")
ElseIf percentage > 45 Then
Console.WriteLine("Second division")
ElseIf percentage > 33 Then
Console.WriteLine("Third division")
Else
Console.WriteLine("You are failed")
End If
End Sub
End Module
Explanation:
We created a Module1 module in the above program that contains a method Main(). We created a variable percentage with an initial value of 0, in the Main() method.
Console.Write("Enter percentage: ") percentage = Double.Parse(Console.ReadLine())
In the above code, we read the value of variable percentage from user.
If percentage > 60 Then Console.WriteLine("First division") ElseIf percentage > 45 Then Console.WriteLine("Second division") ElseIf percentage > 33 Then Console.WriteLine("Third division") Else Console.WriteLine("You are failed") End If
We find the division of students based on a given percentage in the above code and print the division on the console screen.