static void Main(string[] args) { //if-else结构 //如果考试成绩大于80分,则可以吃KFC Console.WriteLine("请输入你的考试成绩"); //提示输入考试成绩 int score = Convert.ToInt32(Console.ReadLine()); //输入考试成绩
//如果成绩大于等于80则可以吃KFC
bool b = score >= 80;
//如果你想表示的含义是当b的值为true的时候去执行if中代码,
//那么 语法上 ==true可以省略
//但是,如果你想表示的是当b==false的时候去执行if中代码,
//语法上 ==false不能省略
if (b)
{
Console.WriteLine("这次考试成绩不错,可以吃KFC了");
}
else
{
Console.WriteLine("这次考试没考好,希望继续努力哦");
}
Console.ReadKey();
}