课程名称 C#程序设计
实验名称 实验一
肆、第四题
一、实验题目
编写一个控制台程序,在该程序中定义一个学生类和班级类,以处理每个学生的学号、姓名、语文、数学和英语3门课程的期末考试成绩。
二、实验要求
(1)能查询每个学生的总成绩;
(2)能显示单科成绩最高分和该科不及格的学生名单;
(3)能统计全班学生的平均成绩;
(4)能对班级学生的各科成绩进行排序
三、实验代码以及执行结果
1、Student类:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 第四题
{
class Student
{
private string number; //学号
private string name; //姓名
private double chineseScore; //语文成绩
private double mathScore; //数学成绩
private double englishScore; //英语成绩
private double avgScore; //三科的平均成绩
public Student(string number, string name, double chineseScore, double mathScore, double englishScore)
{
this.number = number;
this.name = name;
this.chineseScore = chineseScore;
this.mathScore = mathScore;
this.englishScore = englishScore;
avgScore = (chineseScore + mathScore + englishScore) / 3;
}
public double ChineseScore {
get => chineseScore; set => chineseScore = value; }
public double MathScore {
get => mathScore; set => mathScore = value; }
public double EnglishScore {
get => englishScore; set => englishScore = value; }
public double AvgScore {
get => avgScore; set => avgScore = value; }
public string Name {
get => name; set => name = value; }
public void showMessage() //展示当前学生的信息
{
Console.WriteLine("姓名:{0} 学号:{1} 语文成绩:{2} 数学成绩:{3} 英语成绩:{4}\n", name, number, chineseScore, mathScore, englishScore);
}
public double totalScore() //获取当前学生的语数外总成绩
{
return chineseScore <

最低0.47元/天 解锁文章
1325





