using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication16
{
class Program
{
static void Main(string[] args)
{
double a = 5000; //bool b=true;
Console.WriteLine("请输入该员工的年末评级!");
string s = Console.ReadLine();
switch (s)
{
case "A": a += 500;
break;
case "B": a += 100;
break;
case "C": a += 0;
break;
case "D": a -= 100;
break;
case "E": a -= 500;
break;
default: b = false;
break;
}
if(b=true)
{
Console.WriteLine ("明年该员工的工资为{0}。",a);
}
Console.ReadKey();
}
}
}
改进程序
加入bool值 b 控制是否输出
练习
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication17
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入你的姓名!猜测你上辈子职业!");
string name = Console.ReadLine();
//老杨 老胡 老牛 老张 老黑 老陈
switch(name)
{
case "老杨": Console.WriteLine("你上辈子是挑粪的");
break;
case "老胡": Console.WriteLine("你上辈子是老病猫");
break;
case "老牛": Console.WriteLine("你上辈子是杀猪的");
break;
case "老张": Console.WriteLine("你上辈子是跟班");
break;
case "老黑": Console.WriteLine("你上辈子是赌徒");
break;
case "老陈": Console.WriteLine("你上辈子是酸菜头");
break;
default: Console.WriteLine("不认识,你上辈子估计是一坨翔");
break;
}
Console.ReadKey();
}
}
}