.NET Practical Slip 5 Q A

This VB.NET program helps students understand character input handling, conditional statements, and string functions by checking whether a character is a vowel or consonant and identifying its case (uppercase or lowercase).

Slip 5 Q.A) Problem Statement

Q. Write a VB.NET program to accept a character from the keyboard and check whether it is a vowel or consonant. Also, display the case of that character. 15 Marks

Answer:

Algorithm / Logic

  1. Accept a single character from the user using keyboard input.
  2. Check whether the entered character is an alphabet.
  3. Convert the character to lowercase for easy comparison.
  4. Check if the character is a vowel (a, e, i, o, u).
  5. If it is not a vowel, declare it as a consonant.
  6. Check whether the character is in uppercase or lowercase.
  7. Display whether the character is a vowel or consonant and its case.

Source Code

Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim ch As Char
        ch = TextBox1.Text
        Select Case ch
            Case "A", "E", "I", "O", "U"
                MessageBox.Show(ch + " is Vowel And UpperCase")
            Case "a", "e", "i", "o", "u"
                MessageBox.Show(ch + " is Vowel And LowerCase")
            Case Else
                MessageBox.Show(ch + " is consonant")
        End Select
    End Sub
End Class

FAQ Section

1. What is a vowel?

A vowel is a letter such as a, e, i, o, u that produces an open sound.

2. What is a consonant?

A consonant is an alphabet letter that is not a vowel.

3. How do you accept input from the keyboard in VB.NET?

Using the Console.ReadLine() method.

4. How do you check whether a character is uppercase or lowercase in VB.NET?

By using Char.IsUpper() and Char.IsLower() functions.

5. What data type is used to store a single character in VB.NET?

The Char data type.

Helpful Links

Spread the love

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top