温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

怎么使用C#实现简单学生成绩管理系统

发布时间:2022-08-04 09:57:04 来源:亿速云 阅读:142 作者:iii 栏目:开发技术

这篇文章主要介绍“怎么使用C#实现简单学生成绩管理系统”,在日常操作中,相信很多人在怎么使用C#实现简单学生成绩管理系统问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”怎么使用C#实现简单学生成绩管理系统”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

C#作业 用循环结构/数组实现

进入启动页面

怎么使用C#实现简单学生成绩管理系统

管理员身份登入

用户名:师晓峰
密码:88481234

怎么使用C#实现简单学生成绩管理系统

学生成绩输入

默认输入三位同学

怎么使用C#实现简单学生成绩管理系统

学生成绩输出

怎么使用C#实现简单学生成绩管理系统

学生成绩查询

默认按照学号查询

怎么使用C#实现简单学生成绩管理系统

学生成绩修改

学生的学号是固定不变的,通过学号定位学生。

怎么使用C#实现简单学生成绩管理系统

修改功能展示

怎么使用C#实现简单学生成绩管理系统

退出系统

怎么使用C#实现简单学生成绩管理系统

using System;
using System.Net.Http.Headers;
namespace Dome13
{
    class Program
    {
        static void Main(string[] args)
         {
            Console.WriteLine("********欢迎进入启动界面*********");
            Console.WriteLine("******系统名称:晓氏工作室*******");
            Console.WriteLine("******开发人姓名:师晓峰*********");
            Console.WriteLine("******开发时间:2020-10-17*******");
            if (true)
            {
                Console.WriteLine("********欢迎进入用户登录页面*********");
                Console.WriteLine("请输入用户名:");
                string userName = Console.ReadLine();
                Console.WriteLine("请输入密码:");
                string  passWord = Console.ReadLine();
                string uN = "师晓峰";
                string pW = "88481234";
                int count = 2;
                while (true)
                {

                    if (userName == uN && passWord == pW)
                    {
                        Console.WriteLine("********恭喜您登录成功*********");
                        Console.WriteLine("******欢迎进入功能菜单栏*******");
                        // 1.学生成绩输入 2.学生成绩输出 3.学生成绩查询 4.学生成绩修改 0.退出系统
                        Console.WriteLine("******1.学生成绩输入*******");
                        Console.WriteLine("******2.学生成绩输出*******");
                        Console.WriteLine("******3.学生成绩查询*******");
                        Console.WriteLine("******4.学生成绩修改*******");
                        Console.WriteLine("******0.退出系统***********");
                        break;

                    }
                    else
                    {
                        if (count > 0)
                        {
                            Console.WriteLine("您输入的用户名或密码错误,请重新输入");
                            Console.WriteLine("您还有{0}次机会哦!!!", count--);
                            Console.WriteLine("请输入用户名:");
                            userName = Console.ReadLine();
                            Console.WriteLine("请输入密码:");
                            passWord = Console.ReadLine();
                         
                        }
                    }
                }
       const int N_S = 3;
       string[,] student = new string[N_S ,7];
       int n = int.Parse(Console.ReadLine());
       while (true)
           {
           switch (n)
           {
           case 1:
                                Console.WriteLine(" 1.学生成绩输入");
                            InputStudent(student, N_S);
                            break;
                            case 2:
                                Console.WriteLine(" 2.学生成绩输出");
                            OutStudent(student, N_S);
                                break;
                                case 3:
                                Console.WriteLine(" 3.学生成绩查询");
                            Console.WriteLine("请输入学号:");
                            string id = Console.ReadLine();
                            InquierStudent(student ,id);
                               break;
                            case 4:
                                Console.WriteLine(" 4.学生成绩修改");
                            Console.WriteLine("学号固定不变,按照学号查找");
                            Console.WriteLine("请输入学号:");
                            string id1 = Console.ReadLine();
                            AmendStudent(student,id1);
                            break;
                        case 0:
                        Console.WriteLine(" 0.退出系统");
                                break;
                        default:
                            Console.WriteLine("您输入的数字有误,请重新输入(0~4)");
                            break;      
                        }
                          Console.WriteLine();
                    Console.WriteLine("******欢迎进入功能菜单栏*******");
                    Console.WriteLine("******1.学生成绩输入*******");
                    Console.WriteLine("******2.学生成绩输出*******");
                    Console.WriteLine("******3.学生成绩查询*******");
                    Console.WriteLine("******4.学生成绩修改*******");
                    Console.WriteLine("******0.退出系统***********");
                    Console.WriteLine("请选择功能:");
                      n =int.Parse ( Console.ReadLine());
                                      }
                
            }
             static void InputStudent(String[,]student ,int num)
              {
                int temp;
                string strStudent;
                string[] strInof;
                Console.WriteLine("请输入学生信息(以·分隔开):学号·姓名·语文·数学·英语");
                for (int i=0;i<num;i++)
                {
                    Console.WriteLine("请输入第{0}个学生的信息。",i+1);
                    strStudent = Console.ReadLine();
                    strInof = strStudent.Split('·');
                 for (int j=0;j<strInof.Length;j++)
                    {
                        student[i,j] = strInof[j];
                    }
                    Console.WriteLine();
                    //计算总分
                    temp = Convert.ToInt32(student[i,2]) + Convert.ToInt32(student[i,3]) + Convert.ToInt32(student[i,4]);
                    student[i,5] = Convert.ToString(temp);
                    //计算平均分
                    student[i,6] = string .Format ("{0:F2}",temp /3.0);
                }
            }
            static void OutStudent(string[,] student ,int num)
            {
            Console.WriteLine();
                    Console.WriteLine("**********************该学生的信息***************************");
                    Console.WriteLine("|------------------------------------------------------------|");
                    Console.WriteLine("|   学号  |  姓名  |  语文 |  数学 |  英语 |  总分  | 平均分 |");
                    Console.WriteLine("|------------------------------------------------------------|");
                     for (int i=0;i<num;i++)
                {
                    Console.WriteLine("| {0,10} | {1,3} | {2,4} | {3,4} | {4,4} | {5,5}|  {6,6:F2}  |",student[i,0],student [i,1],student [i,2],student [i,3],student [i,4],student [i,5],student [i,6]);
                    Console.WriteLine("|------------------------------------------------------------|");
                }
            }
              static void InquierStudent(String[,]student,string  id){
                int i = 0;
                 for (;i<student .Length; i++)
                {
                    if (student[i,0]==id)
                    {
                    Console.WriteLine("**********************该学生的信息***********************");
                        Console.WriteLine("|--------------------------------------------------------|");
                        Console.WriteLine("|  学号  | 姓名  | 语文 | 数学 | 英语 | 总分  |  平均分  |");
                        Console.WriteLine("|--------------------------------------------------------|");
                        Console.WriteLine("| {0,10} | {1,3} |{2,4}| {3,4} | {4,4} | {5,5}| {6,6:F2} |", student[i,0], student[i,1], student[i,2], student[i, 3], student[i,4], student[i, 5], student[i,6]);
                        Console.WriteLine("|--------------------------------------------------------|");
                        break;
                    }
                  }
                if(i>=student.Length)
                 {
                    Console.WriteLine("查询失败,您输入的学号有误!!!!");
                }
            }
            static void AmendStudent(String[,] student, string id1)
            {
                int i = 0;
                for (; i < student.Length; i++)
                {
                    if (student[i, 0] == id1)
                    {
                     Console.WriteLine("**************************该学生的信息**********************");
                        Console.WriteLine("|----------------------------------------------------------|");
                        Console.WriteLine("| 学号  | 姓名  |  语文 |  数学  | 英语  |  总分 | 平均分  |");
                        Console.WriteLine("|----------------------------------------------------------|");
                        Console.WriteLine("|{0,10} | {1,3} | {2,4} | {3,4}  | {4,4} | {5,5} | {6,6:F2}|", student[i,0], student[i,1], student[i,2], student[i,3], student[i,4], student[i,5], student[i,6]);
                        Console.WriteLine("|----------------------------------------------------------|");
                        Console.WriteLine();
                        int temp = 0;
                        Console.WriteLine("-------------------------");
                        Console.WriteLine("******1.修改姓名*********");
                        Console.WriteLine("******2.修改语文成绩*****");
                        Console.WriteLine("******3.修改数学成绩*****");
                        Console.WriteLine("******4.修改英语成绩*****");
                        Console.WriteLine("******0.退出修改*********");
                        Console.WriteLine("-------------------------");
                        Console.WriteLine("请输入要修改的选项(对应的序号)");
                        int j = int.Parse(Console.ReadLine());
                        while (j != 0)
                        {
                            switch (j)
                            {
                                case 1:
                                 Console.WriteLine("请输入修改后的姓名:");
                                    student[i, 1] = Console.ReadLine();
                                    break;
                                     case 2:
                                    Console.WriteLine("请输入修改后的语文:");
                                    student[i, 2] = Console.ReadLine();
                                    break;
                                case 3:
                                    Console.WriteLine("请输入修改后的数学:");
                                    student[i, 3] = Console.ReadLine();
                                    break;
                                case 4:
                                    Console.WriteLine("请输入修改后的英语:");
                                    student[i, 4] = Console.ReadLine();
                                    break;
                                case 0:
                                    Console.WriteLine("******0.退出修改*********");
                                    break;
                                default:
                                    Console.WriteLine("您输入的序号错误,请重新输入");
                                    break;
                                     }
                           Console.WriteLine("请输入要修改的选项(对应的序号1`4)");
                            j = int.Parse(Console.ReadLine());
                        }
                         temp = Convert.ToInt32(student [i,2]) + Convert.ToInt32(student[i,3]) + Convert.ToInt32(student[i,4]);
                            student[i, 5] = Convert.ToString(temp);
                            //计算平均分
                            student[i, 6] = string.Format("{0:F2}", temp / 3.0);
                             Console.WriteLine("**********************修改侯该学生的信息***********************");
                            Console.WriteLine("|-------------------------------------------------------------|");
                            Console.WriteLine("| 学号  | 姓名  |  语文 |  数学  | 英语  | 总分  |    平均分  |");
                            Console.WriteLine("|-------------------------------------------------------------|");
                            Console.WriteLine("|{0,10} | {1,3} | {2,4} |  {3,4} | {4,4} | {5,5} |  {6,6:F2}  |", student[i,0], student[i,1], student[i,2], student[i,3], student[i,4], student[i,5], student[i,6]);
                            Console.WriteLine("|-------------------------------------------------------------|");
                            Console.WriteLine();
                            break;
                            
                    }
                    if (i>=student .Length )
                    {
                        Console.WriteLine("查找失败,您输入的学号有误!!!");
                    }
                    Console.ReadKey();
                }
            }
       }
    }
}

到此,关于“怎么使用C#实现简单学生成绩管理系统”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI