7.编程实现从键盘接收输入分数,然后对分数进行等级输出(90-100为A,80-89为B,70-79为C,60-69为D,60以下为E),如输入93,打印输出你的分数为93,等级为A.
时间: 2024-03-25 20:36:45 浏览: 9
好的,这个问题可以用 Python 语言来实现。下面是代码示例:
```python
score = int(input("请输入分数:"))
if score >= 90:
grade = "A"
elif score >= 80:
grade = "B"
elif score >= 70:
grade = "C"
elif score >= 60:
grade = "D"
else:
grade = "E"
print("你的分数为{},等级为{}".format(score, grade))
```
运行代码后,你可以输入一个分数,然后程序会自动输出对应的等级。
相关问题
用c语言编程,若输入的分数在85~100之间,则输出等级为A
以下是用C语言实现上述功能的代码:
```c
#include <stdio.h>
int main() {
int score;
printf("请输入分数:");
scanf("%d", &score);
if (score >= 85 && score <= 100) {
printf("等级为A\n");
}
return 0;
}
```
首先,通过 `printf` 函数输出提示信息,让用户输入分数。然后,通过 `scanf` 函数读取用户输入的分数。接着,使用 `if` 语句判断分数是否在85~100之间,如果满足条件,则输出等级为A。最后,程序通过 `return` 语句结束。
定义一个类,在main方法中写代码,实现从键盘输入就来百分制成绩,转换成等级制成绩输出。 规则:100--90 A 89--80 B 79--70 C 69--60 D 59--0 E
好的,这是一个关于编程的问题,我可以回答。以下是代码实现:
#include <iostream>
using namespace std;
class GradeConverter {
public:
void convert() {
int score;
cout << "请输入百分制成绩:";
cin >> score;
if (score >= 90 && score <= 100) {
cout << "等级制成绩为:A" << endl;
} else if (score >= 80 && score <= 89) {
cout << "等级制成绩为:B" << endl;
} else if (score >= 70 && score <= 79) {
cout << "等级制成绩为:C" << endl;
} else if (score >= 60 && score <= 69) {
cout << "等级制成绩为:D" << endl;
} else if (score >= && score <= 59) {
cout << "等级制成绩为:E" << endl;
} else {
cout << "输入的成绩不合法!" << endl;
}
}
};
int main() {
GradeConverter gc;
gc.convert();
return ;
}
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)