程序检查值是数字,符号(?,。!)还是元音(a,e,i,o,u) [英] Program check if the value is number, sign (?,.!) or vowel (a,e,i,o,u)

查看:98
本文介绍了程序检查值是数字,符号(?,。!)还是元音(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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆