Nested If Example

Nested If Else Example

Imports System.Collections.Generic
Imports System.Linq
Imports System.Text

Namespace ConsoleApplication1
    Class Program
        Private Shared Sub Main(ByVal args As String())
            Dim m, p, c, avg As Integer
            Console.WriteLine("Enter maths,phy,che marks")
            m = Integer.Parse(Console.ReadLine())
            p = Integer.Parse(Console.ReadLine())
            c = Integer.Parse(Console.ReadLine())
            avg = (m + p + c) / 3

            If m > 34 AndAlso p > 34 AndAlso c > 34 Then

                If avg > 34 AndAlso avg < 50 Then
                    Console.WriteLine("Oridinary")
                Else

                    If avg >= 50 AndAlso avg < 60 Then
                        Console.WriteLine("Second")
                    Else

                        If avg >= 60 AndAlso avg < 75 Then
                            Console.WriteLine("First")
                        ElseIf avg >= 75 Then
                            Console.WriteLine("Distinction")
                        End If
                    End If
                End If
            Else
                Console.WriteLine("Fail")
            End If
        End Sub
    End Class
End Namespace


Or

Imports System.Collections.Generic
Imports System.Linq
Imports System.Text

Namespace ConsoleApplication1
    Class Program
        Private Shared Sub Main(ByVal args As String())
            Dim m, p, c, avg As Integer
            Console.WriteLine("Enter maths,phy,che marks")
            m = Integer.Parse(Console.ReadLine())
            p = Integer.Parse(Console.ReadLine())
            c = Integer.Parse(Console.ReadLine())
            avg = (m + p + c) / 3

            If m > 34 AndAlso p > 34 AndAlso c > 34 Then

                If avg > 34 AndAlso avg < 50 Then
                    Console.WriteLine("Oridinary")
                ElseIf avg >= 50 AndAlso avg < 60 Then
                    Console.WriteLine("Second")
                ElseIf avg >= 60 AndAlso avg < 75 Then
                    Console.WriteLine("First")
                ElseIf avg >= 75 Then
                    Console.WriteLine("Distinction")
                End If
            Else
                Console.WriteLine("Fail")
            End If
        End Sub
    End Class
End Namespace


©Copyright 2016 All Rights Reserved LearnDotNetHome.com