Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace CheckPlayCard
- {
- class CheckForACard
- {
- static void Main()
- {
- bool isNumber = false;
- bool isInside = false;
- int number = 0;
- char[] cards = { 'J', 'Q', 'K', 'A' };
- Console.WriteLine("Enter a playing card:");
- string input = Console.ReadLine();
- input = input.ToUpper();
- isNumber = int.TryParse(input, out number);
- if(isNumber)
- {
- if (number >= 2 && number <= 10)
- {
- isInside = true;
- }
- else
- {
- isInside = false;
- }
- }
- else if(!isNumber)
- {
- foreach (var card in cards)
- {
- if(card == Convert.ToChar(input))
- {
- isInside = true;
- }
- }
- }
- Console.WriteLine(isInside? "Yes":"No");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement