Answer to Question #60185 in C# for RD

Question #60185
Write a program in C++ to input a single character and print a message― it is vowel" if it is vowel otherwise print message "It is a "consonant― Use if-else structure and OR (||) operator only.
1
Expert's answer
2016-06-02T10:09:03-0400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Question
{

class Letter_Class
{
private char letter;

public char Letter
{
get { return letter; }
set { letter = value; }
}

public bool IsVowel()
{
char letterUp = Char.ToUpper(letter);
if (letterUp == 'A' || letterUp == 'O' || letterUp == 'U' || letterUp == 'I' || letterUp == 'E')
return true;
else
return false;
}
}
class Program
{
static void Main(string[] args)
{
Console.Write("Input letter: ");
char letter = Console.ReadKey().KeyChar;
Console.WriteLine();
Letter_Class LetterObj = new Letter_Class();
LetterObj.Letter = letter;

if (LetterObj.IsVowel())
Console.WriteLine("It is a vowel!");
else
Console.WriteLine("It is a consonaut!");

}
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS