c# - 为什么我的代码会给出“异常”作为结果
问题描述
我正在尝试创建一个函数,该函数根据用户输入(短、平均或高)显示人的身高。如果用户输入其他内容,则显示“异常”这里的问题是我只得到异常作为所有输入的结果。
using System;
public class program
{
public static void Main()
{
int a;
Console.WriteLine("Enter the Height: ");
a = Convert.ToInt32(Console.ReadLine());
switch (a)
{
case 1:
if (a < 150)
Console.WriteLine("Short");
break;
case 2:
if ((a >= 150) && (a <= 165))
Console.WriteLine("Average");
break;
case 3:
if ((a >= 166) && (a <= 195))
Console.WriteLine("Tall");
break;
default:
Console.WriteLine("Abnormal");
break;
}
}
}
解决方案
推荐阅读
- docker - Kibana Docker“这可能需要几分钟”但从不启动
- arrays - 将数组存储在数据库 Wordpress 中
- javascript - Javascript - 将分隔文本拆分为列
- c# - c# "is" 与存储在变量中的类型比较 --
- android - 棒棒糖前的矢量可绘制崩溃
- xamarin - 如何在 ViewCellRenderer Xamarin.Forms 中获取按钮单击事件
- azure-devops - VSTS - 测试 -> 运行 -> 查询端点未根据参数进行过滤
- asp.net-core - 具有招摇属性的 CreatedAtRouteResult
- python - python ValueError:解包的值太多(预期....)
- javascript - 允许按钮被点击一次 JavaScript