C#中switch语句使用

编写一个程序,使用 switch 语句将用户输入的分数转换成等级,如表

private static void Main(string[] args)

{

Console.WriteLine("请输入分数:");

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

switch (score)

{

case 90:

case 91:

case 92:

case 93:

case 94:

case 95:

case 96:

case 97:

case 98:

case 99:

case 100:

Console.WriteLine("A");

break;

case 80:

case 81:

case 82:

case 83:

case 84:

case 85:

case 86:

case 87:

case 88:

case 89:

Console.WriteLine("B");

break;

case 70:

case 71:

case 72:

case 73:

case 74:

case 75:

case 76:

case 77:

case 78:

case 79:

Console.WriteLine("C");

break;

case 60:

case 61:

case 62:

case 63:

case 64:

case 65:

case 66:

case 67:

case 68:

case 69:

Console.WriteLine("D");

break;

default:

Console.WriteLine("E");

break;

}

}

相关推荐
DechinPhy11 小时前
Ubuntu挂载新硬盘
linux·运维·服务器·ubuntu
SoaringHeart11 小时前
Flutter封装:原生路由管理极简封装 AppNavigator
前端·flutter
menu11 小时前
AI给我的建议
前端
张可爱11 小时前
20251018-JavaScript八股文整理版(上篇)
前端
小小测试开发11 小时前
Python Arrow库:告别datetime繁琐,优雅处理时间与时区
开发语言·前端·python
自律版Zz11 小时前
手写 Promise.resolve:从使用场景到实现的完整推导
前端·javascript
golang学习记11 小时前
从0死磕全栈之Next.js 自定义 Server 指南:何时使用及如何实现
前端
张可爱11 小时前
从奶茶店悟透 JavaScript:递归、继承、浮点数精度、尾递归全解析(通俗易懂版)
前端
ysdysyn11 小时前
.NET 10深度解析:性能革新与开发生态的全新篇章
c#·.net