1. 编写程序,计算某学生奖学金的等级,以三门课程分数为评奖依据。奖学金评奖标准 如下: 符合下列条件之一者获一等奖: (1)平均分大于 95 分者; (2)有两门分数是 100 分,且第三门课程分数不低于 80 分者。 符合下列条件之一者获二等奖: (1)平均分大于 90 分者; (2)有一门分数是 100 分,且其他课程分数不低于 75 分者。 符合下列条件者获三等奖: 各门功课分数不低于 70 分。 符合条件者就高不就低,只能获得高的那一项奖学金。要求显示获奖的等级。
时间: 2024-02-05 17:11:14 浏览: 38
以下是Python代码实现:
```python
score1 = int(input("请输入第一门课程的分数:"))
score2 = int(input("请输入第二门课程的分数:"))
score3 = int(input("请输入第三门课程的分数:"))
average_score = (score1 + score2 + score3) / 3 # 计算平均分
if average_score > 95 or (score1 == 100 and score2 == 100 and score3 >= 80):
print("恭喜你获得一等奖学金!")
elif average_score > 90 or (score1 == 100 and score2 >= 75 and score3 >= 75) or (score2 == 100 and score1 >= 75 and score3 >= 75) or (score3 == 100 and score1 >= 75 and score2 >= 75):
print("恭喜你获得二等奖学金!")
elif score1 >= 70 and score2 >= 70 and score3 >= 70:
print("恭喜你获得三等奖学金!")
else:
print("很遗憾,你没有获得奖学金。")
```
通过用户输入三门课程的分数,计算平均分,并根据奖学金评奖标准判断获奖等级,最后输出获奖等级。
相关问题
应用列表ArrayList 编写程序,存储学生的学号,姓名,计算机,数学,英语,三门课程
以下是一个示例代码,用于存储学生的学号、姓名、计算机、数学、英语三门课程信息:
```java
import java.util.ArrayList;
public class Student {
private int id;
private String name;
private double computerScore;
private double mathScore;
private double englishScore;
public Student(int id, String name, double computerScore, double mathScore, double englishScore) {
this.id = id;
this.name = name;
this.computerScore = computerScore;
this.mathScore = mathScore;
this.englishScore = englishScore;
}
public int getId() {
return id;
}
public String getName() {
return name;
}
public double getComputerScore() {
return computerScore;
}
public double getMathScore() {
return mathScore;
}
public double getEnglishScore() {
return englishScore;
}
public static void main(String[] args) {
ArrayList<Student> students = new ArrayList<>();
// 添加学生信息
students.add(new Student(1, "张三", 90.5, 85.0, 92.5));
students.add(new Student(2, "李四", 78.0, 95.5, 87.5));
students.add(new Student(3, "王五", 82.5, 91.0, 89.5));
// 输出学生信息
for(Student student : students) {
System.out.printf("学号:%d,姓名:%s,计算机成绩:%.1f,数学成绩:%.1f,英语成绩:%.1f\n",
student.getId(), student.getName(),
student.getComputerScore(), student.getMathScore(), student.getEnglishScore());
}
}
}
```
运行结果如下:
```
学号:1,姓名:张三,计算机成绩:90.5,数学成绩:85.0,英语成绩:92.5
学号:2,姓名:李四,计算机成绩:78.0,数学成绩:95.5,英语成绩:87.5
学号:3,姓名:王五,计算机成绩:82.5,数学成绩:91.0,英语成绩:89.5
```
用c语言写个程序:按姓名查找某名学生三门课程成绩并显示出来
好的,以下是用C语言编写的程序,可以按照姓名查找某名学生的三门课程成绩并显示出来:
```c
#include <stdio.h>
#include <string.h>
struct student {
char name[20];
int score1;
int score2;
int score3;
};
int main() {
struct student st[5];
int i, flag = 0;
char s[20];
// 输入学生信息
printf("请输入5个学生的姓名及三门课程成绩:\n");
for (i = 0; i < 5; i++) {
scanf("%s %d %d %d", st[i].name, &st[i].score1, &st[i].score2, &st[i].score3);
}
// 输入要查找的学生姓名
printf("请输入要查找的学生姓名:");
scanf("%s", s);
// 查找学生信息
for (i = 0; i < 5; i++) {
if (strcmp(s, st[i].name) == 0) {
printf("%s的三门课程成绩分别为:%d %d %d\n", st[i].name, st[i].score1, st[i].score2, st[i].score3);
flag = 1;
break;
}
}
// 若未找到该学生信息,则输出提示信息
if (flag == 0) {
printf("未找到该学生的信息!\n");
}
return 0;
}
```
这个程序中,我们使用了结构体来存储学生的姓名和三门课程成绩,然后通过循环来输入5个学生的信息。接着,用户可以输入要查找的学生姓名,程序会遍历所有学生的信息,查找该学生的信息并输出。如果未找到该学生的信息,则会输出提示信息。
相关推荐
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.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)