c#流程控制

if

Console.WriteLine("请输入用户名");
string name = Console.ReadLine();
Console.WriteLine("请输入密码");
string passWord = Console.ReadLine();
bool d = (name == "admin" && passWord == "111111");
if (d)
{
    Console.WriteLine("登陆成功哦!");
}
Console.ReadKey();

if-else

Console.WriteLine("小马,你的数学考了多少分?");
int score = Convert.ToInt32(Console.ReadLine());
if (score > 90)
{
    Console.WriteLine("奖励你100元哦");
}
else
{
    Console.WriteLine("奖励你最爱吃的大嘴巴子哦");
}
Console.ReadKey();

if-else if

Console.WriteLine("你是谁阿");
string s = Console.ReadLine().ToString();
if (s == "爷爷")
{
   Console.WriteLine("grandpa");
}
else if (s == "爸爸")
{
   Console.WriteLine("dad");
}
else if (s == "儿子")
{
   Console.WriteLine("son");
}
Console.ReadKey();

switch-case

bool b = true;
double salary = 5000;
Console.WriteLine("请输入赵鸡的工作评定等级");
string level = Console.ReadLine();
switch (level)
{
   case "a": salary += 500;
       break;
   case "b": salary += 300;
       break;
   case "c": salary += 100;
       break;
   default: Console.WriteLine("程序有误,请重新输入");
       b = false;
       break;
}
if (b)
{
   Console.WriteLine("赵鸡明年的工资为{0}元", salary);
}
Console.ReadKey();

 

转载于:https://www.cnblogs.com/huangxuQaQ/p/10725640.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值