C#分支结构选择结构IF、SWITCH判断学生成绩是否及格区间

  • Post author:
  • Post category:其他


			int score = 90;
			
			
			if(score >= 90){
			   textBox1.Text = "优秀";
			
			}
			else if (score >= 80 && score < 90) {
			   textBox1.Text = "良好";
			
			
			}else if(score >=70 && score<80){
			   textBox1.Text = "中等";
			
			}else if (score >=60 && score<70){
			   textBox1.Text = "及格";
			}else{
			   textBox1.Text = "不及格";
			
			}

			switch(score / 10){
			case 10:
				textBox1.Text = "优秀";break;
			case 9:
				textBox1.Text = "优秀";break;
			case 8:
				textBox1.Text = "良好";break;
			case 7:
				textBox1.Text = "中等";break;
			case 6:
				textBox1.Text = "及格";break;
			default:
				textBox1.Text = "不及格";break;
			
			}



版权声明:本文为CongJiYong原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。