kirililchev3

Vowel or Digit - try catch, bool, char

May 27th, 2018
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | None | 0 0
  1. using System;
  2.  
  3. namespace P13_VowelOrDigit
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             var symbol = Console.ReadLine();
  10.             try
  11.             {
  12.                 int.Parse(symbol);
  13.                 Console.WriteLine("digit");
  14.             }
  15.             catch (Exception)
  16.             {
  17.  
  18.                 char letter = char.Parse(symbol);
  19.                 bool isLetterAVowel =
  20.                     letter == 'a' ||
  21.                     letter == 'o' ||
  22.                     letter == 'u' ||
  23.                     letter == 'e' ||
  24.                     letter == 'i';
  25.                 Console.WriteLine(isLetterAVowel ? "vowel" : "other");
  26.             }
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment