Switch Learn programming Visual Basic (VB.net)

Lesson:

Flow Control


Exercise:

Switch 107


Objetive:

Create a program in Visual Basic (VB.net) to display the "text mark" corresponding to a certain "numeric mark", using the following equivalence:

9.10 = Outstanding
7.8 = Notable
6 = Good
5 = Approved
0-4 = Suspense

Your program should ask the user for a numerical mark and display the corresponding text mark. You need to do it twice: first using "if" and then using "switch".
9,10 = Sobresaliente
7,8 = Notable
6 = Bien
5 = Aprobado
0-4 = Suspenso

Your program must ask the user for a numerical mark and display the corresponding text mark. You must do it twice: first using "if" and then using "switch".


Code:

Imports System
Public Class Exercise44
    Public Shared Sub Main()
        Dim number As Integer
        Console.Write("Number? ")
        number = Convert.ToInt32(Console.ReadLine())

        If (number = 9) OrElse (number = 10) Then
            Console.WriteLine("Sobresaliente")
        ElseIf (number = 7) OrElse (number = 8) Then
            Console.WriteLine("Notable")
        ElseIf number = 6 Then
            Console.WriteLine("Bien")
        ElseIf number = 5 Then
            Console.WriteLine("Aprobado")
        ElseIf (number >= 0) AndAlso (number <= 4) Then
            Console.WriteLine("Suspenso")
        Else
            Console.WriteLine("No válido")
        End If

        Select Case number
            Case 0, 1, 2, 3, 4
                Console.WriteLine("Suspenso")
            Case 5
                Console.WriteLine("Aprobado")
            Case 6
                Console.WriteLine("Bien")
            Case 7
                GoTo _Select0_Case8
            Case 8
_Select0_Case8:
                Console.WriteLine("Notable")
            Case 9
                Console.WriteLine("Bajo, pero... ")
                GoTo _Select0_Case10
            Case 10
_Select0_Case10:
                Console.WriteLine("Sobresaliente")
            Case Else
                Console.WriteLine("Nota no válida")
        End Select
    End Sub
End Class