C#程序设计实验报告面向对象程序设计(实验1第四题)附源码

课程名称 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 <
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

别卷了,球球了。

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值