您的位置:首页 > 编程语言 > C#

C#逻辑判断输入值后返回提示信息。

2011-09-13 15:34 351 查看
// VS中新建控制台程序,用以下源码运行后在cmd中提示及返回值。CSC提示找不到!

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

Console.WriteLine("欢迎光临本商场" + "\n" + "你今天花了多少钱啊?");

int input = int.Parse((Console.ReadLine()));

string Display;

if (input < 5)

{

Display = "你可以走了!";

}

else if (input > 5 && input < 20)

{

Display = "奖励你一杯咖啡!";

}

else if (input > 20 && input < 30)

{

Display = "送你五块钱";

}

else if (input > 30 && input < 50)

{

Display = "你是疯子哇!";

}

else

{

Display = "早点回去睡觉吧!";

}

Console.WriteLine(Display + "\n再见!不送。");

Console.ReadKey();

}

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐