程序检查值是数字,符号(?,。!)还是元音(a,e,i,o,u) [英] Program check if the value is number, sign (?,.!) or vowel (a,e,i,o,u)
问题描述
所以我需要编写一个程序来检查值是数字,符号还是元音。 *我是新手,这是一个功课,对我来说很难
So I need to write a program to check if the value is number, sign or vowel. *I'm new to this, it's a homework and it's been pretty hard for me
到目前为止我去过这里:                               
SO far i've been to here:
{
      static void Main(string [] args)
      {
int a;
          Console.WriteLine(" Symbol:");
          a = int.Parse(Console.ReadLine());
          string value =" 123.3";
         双倍数;
          if(!double.TryParse(value,out num))
             抛出新的InvalidOperationException("这不是数字。");
          }
{
static void Main(string[] args)
{
int a;
Console.WriteLine("Symbol: ");
a = int.Parse(Console.ReadLine());
string value = "123.3";
double num;
if (!double.TryParse(value, out num))
throw new InvalidOperationException("That's not a number.");
}
}
推荐答案
为了检查它是否为数字:
Console.WriteLine(
" Symbol:" );
string text = Console.ReadLine();
double
如果 (
double 。TryParse(text,
out num))
{
Console.WriteLine( "这是一个数字。" );
Console.WriteLine( "That's a number." );
}
其他
{
//其他检查
// ..
}
在 else 块内,您可以添加符号和元音的验证。
Inside the else block you can add verifications for signs and vowels.
这篇关于程序检查值是数字,符号(?,。!)还是元音(a,e,i,o,u)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!