学生成绩管理系统

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace @string
{
    class Program
    {
        static void Main(string[] args)
        {

            Stu_Manage myuser = new Stu_Manage();
            myuser.Chech();
        }
    }
    public class Student
    {
        public int no;
        public double math, english;
        public double csharp, network;
        public double avg, all;
        public string name;
        //显示学生信息
        public void ShowStuInfo()
        {
            Console.WriteLine("\n学生信息:");
            Console.WriteLine("\n学号:{0}", no);
            Console.WriteLine("\t姓名:{1}:", name);
            Console.WriteLine("\t数学:{2}", math);
            Console.WriteLine("\t英语:{3}", english);
            Console.WriteLine("\t   c#:{4}", csharp);
            Console.WriteLine("\t计算机网络:{5}", network);
            Console.WriteLine("\t平均成绩:{6}", avg);
            Console.WriteLine("\t总成绩:{7}", all);
            Console.WriteLine();
        }
    }
    //定义学生信息管理类
    class Stu_Manage
    {
        int x = 0;
        //声明一个结构体类数组,数组名stud
        Student[] stud = new Student[10];
        //Add()方法添加学生信息
        public void Add()
        {
            Console.WriteLine("请输入要添加的学生的信息:");
            Console.WriteLine("请输入学号:");
            stud[x].no = int.Parse(Console.ReadLine());
            Console.WriteLine("\n请输入姓名:");
            stud[x].name = Console.ReadLine();
            Console.WriteLine("\n数学成绩:");
            stud[x].math = double.Parse(Console.ReadLine());
            Console.WriteLine("\n英语成绩:");
            stud[x].english = double.Parse(Console.ReadLine());
            Console.WriteLine("\nC#成绩:");
            stud[x].csharp = double.Parse(Console.ReadLine());
            Console.WriteLine("\n计算机网络成绩:");
            stud[x].network = double.Parse(Console.ReadLine());
            //定义一个数组将输入的成绩存储
            double[] inform = new double[] { stud[x].math, stud[x].english, stud[x].csharp, stud[x].network };
            for (int i = 0; i < inform.Length; i++)
            {
                stud[x].all += inform[i];
                stud[x].avg = stud[x].all / 4;
                stud[x].ShowStuInfo();
                x = x + 1;
            }
        }
        public void Delete()
        {
            int n = -1;
            int no = int.Parse(Console.ReadLine());
            for (int i = 0; i < x; i++)
            {
                if (no == stud[i].no)
                {
                    n = i;
                    for (int c = n + 1; c < x; c++)
                    {
                        //交换数组索引值,对指定元素进行删除
                        stud[c - 1] = stud[c];
                    }
                    x = x - 1;
                    break;
                }
            }
        }
        public void Search_no()
        {
            int n = -1;
            int no = int.Parse(Console.ReadLine());
            for (int i = 0; i < x; i++)
            {
                if (no == stud[i].no)
                {
                    n = i;
                    stud[i].ShowStuInfo();
                    break;
                }
            }
            if (n == -1)
            {
                Console.WriteLine();
            }
        }
        public void Search_name()
        {
            int n = -1;
            string name = Console.ReadLine();
            for (int i = 0; i < x; i++)
            {
                if (name == stud[i].name)
                {
                    n = i;
                    stud[i].ShowStuInfo();
                    break;
                }
            }
            if (n == -1)
            {
                Console.WriteLine();
            }
        }
        public void Search_score()
        {
            for (int i = x - 1; i >= 0; i--)
            {
                for (int j = 0; j <= i; j++)
                {
                    if (stud[j].all > stud[j + 1].all)
                    {
                        stud[x] = stud[j];
                        stud[j] = stud[j + 1];
                        stud[j + 1] = stud[x];

                    }
                }
            }
            int[] mc = new int[x];
            for (int i = 0; i < x; i++)
            {
                mc[i] = i + 1;
                Console.WriteLine(stud[i].no + "\t");
                Console.WriteLine(stud[i].name + "\t");
                Console.WriteLine(stud[i].math + "\t");
                Console.WriteLine(stud[i].english + "\t");
                Console.WriteLine(stud[i].csharp + "\t");
                Console.WriteLine(stud[i].network + "\t");
                Console.WriteLine(stud[i].avg + "\t");
                Console.WriteLine(stud[i].all + "\t");
                Console.WriteLine();
            }
        }
        public void Chech()
        {
            do
            {
                Console.WriteLine("请选择:\n 1、添加学生信息\n 2、删除学生信息\n 3、查询按学号\n 4、查询按姓名\n 5、查询成绩单\n 6、退出系统");
                int number = int.Parse(Console.ReadLine());
                if (number > 6 || number < 1)
                {
                    Console.WriteLine("输入有误请重新输入");

                }
                switch (number)
                {
                    case 1:
                        Add();
                        break;
                    case 2:
                        Console.WriteLine("请输入要删除学生的学号:");
                        Delete();
                        break;
                    case 3:
                        Console.WriteLine("请输入学号:");
                        Search_no();
                        break;
                    case 4:
                        Console.WriteLine("请输入姓名:");
                        Search_name();
                        break;
                    case 5:
                        Console.WriteLine("成绩单:");
                        Console.WriteLine("名次\t学号\t姓名\t数学\t英语\tC#\t计算机网络\t平均\t总成绩");
                        Search_score();
                        break;
                    case 6:
                        Environment.Exit(0);
                        break;
                }
                Console.WriteLine("\n是否要继续!");
            } while (true);
        }
    }
}

C#.net实现学生成绩管理系统 namespace 学生成绩管理系统 { partial class Formlogin { /// /// 必需的设计器变量。 /// private System.ComponentModel.IContainer components = null; /// /// 清理所有正在使用的资源。 /// /// 如果应释放托管资源,为 true;否则为 false。 protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows 窗体设计器生成的代码 /// /// 设计器支持所需的方法 - 不要 /// 使用代码编辑器修改此方法的内容。 /// private void InitializeComponent() { this.labeluser = new System.Windows.Forms.Label(); this.textBoxuser = new System.Windows.Forms.TextBox(); this.labelcode = new System.Windows.Forms.Label(); this.textBoxcode = new System.Windows.Forms.TextBox(); this.buttonin = new System.Windows.Forms.Button(); this.buttonout = new System.Windows.Forms.Button(); this.SuspendLayout(); // // labeluser // this.labeluser.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.labeluser.Location = new System.Drawing.Point(31, 50); this.labeluser.Name = "labeluser"; this.labeluser.Size = new System.Drawing.Size(55, 26); this.labeluser.TabIndex = 0; this.labeluser.Text = "用户名"; this.labeluser.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // textBoxuser // this.textBoxuser.Location = new System.Drawing.Point(126, 55); this.textBoxuser.Name = "textBoxuser"; this.textBoxuser.Size = new System.Drawing.Size(112, 21); this.textBoxuser.TabIndex = 1; // // labelcode // this.labelcode.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.labelcode.Location = new System.Drawing.Point(31, 124); this.labelcode.Name = "labelcode"; this.labelcode.Size = new System.Drawing.Size(55, 23); this.labelcode.TabIndex = 2; this.labelcode.Text = "密码"; this.labelcode.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // textBoxcode // this.textBoxcode.Location = new System.Drawing.Point(126, 124); this.textBoxcode.Name = "textBoxcode"; this.textBoxcode.PasswordChar = '*'; this.textBoxcode.Size = new System.Drawing.Size(112, 21); this.textBoxcode.TabIndex = 3; // // buttonin // this.buttonin.Location = new System.Drawing.Point(34, 200); this.buttonin.Name = "buttonin"; this.buttonin.Size = new System.Drawing.Size(75, 23); this.buttonin.TabIndex = 4; this.buttonin.Text = "登陆"; this.buttonin.UseVisualStyleBackColor = true; this.buttonin.Click += new System.EventHandler(this.buttonin_Click); // // buttonout // this.buttonout.Location = new System.Drawing.Point(163, 200); this.buttonout.Name = "buttonout"; this.buttonout.Size = new
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值