C#實現(xiàn)簡單學(xué)生成績管理系統(tǒng)
本文實例為大家分享了C#實現(xiàn)學(xué)生成績管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下
C#作業(yè) 用循環(huán)結(jié)構(gòu)/數(shù)組實現(xiàn)
進入啟動頁面

管理員身份登入
用戶名:師曉峰
密碼:88481234

學(xué)生成績輸入
默認輸入三位同學(xué)

學(xué)生成績輸出

學(xué)生成績查詢
默認按照學(xué)號查詢

學(xué)生成績修改
學(xué)生的學(xué)號是固定不變的,通過學(xué)號定位學(xué)生。

修改功能展示

退出系統(tǒng)

using System;
using System.Net.Http.Headers;
namespace Dome13
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? ?{
? ? ? ? ? ? Console.WriteLine("********歡迎進入啟動界面*********");
? ? ? ? ? ? Console.WriteLine("******系統(tǒng)名稱:曉氏工作室*******");
? ? ? ? ? ? Console.WriteLine("******開發(fā)人姓名:師曉峰*********");
? ? ? ? ? ? Console.WriteLine("******開發(fā)時間: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.學(xué)生成績輸入 2.學(xué)生成績輸出 3.學(xué)生成績查詢 4.學(xué)生成績修改 0.退出系統(tǒng)
? ? ? ? ? ? ? ? ? ? ? ? Console.WriteLine("******1.學(xué)生成績輸入*******");
? ? ? ? ? ? ? ? ? ? ? ? Console.WriteLine("******2.學(xué)生成績輸出*******");
? ? ? ? ? ? ? ? ? ? ? ? Console.WriteLine("******3.學(xué)生成績查詢*******");
? ? ? ? ? ? ? ? ? ? ? ? Console.WriteLine("******4.學(xué)生成績修改*******");
? ? ? ? ? ? ? ? ? ? ? ? Console.WriteLine("******0.退出系統(tǒng)***********");
? ? ? ? ? ? ? ? ? ? ? ? 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.學(xué)生成績輸入");
? ? ? ? ? ? ? ? ? ? ? ? ? ? InputStudent(student, N_S);
? ? ? ? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? ? ? ? ? ? ? case 2:
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Console.WriteLine(" 2.學(xué)生成績輸出");
? ? ? ? ? ? ? ? ? ? ? ? ? ? OutStudent(student, N_S);
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? case 3:
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Console.WriteLine(" 3.學(xué)生成績查詢");
? ? ? ? ? ? ? ? ? ? ? ? ? ? Console.WriteLine("請輸入學(xué)號:");
? ? ? ? ? ? ? ? ? ? ? ? ? ? string id = Console.ReadLine();
? ? ? ? ? ? ? ? ? ? ? ? ? ? InquierStudent(student ,id);
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?break;
? ? ? ? ? ? ? ? ? ? ? ? ? ? case 4:
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Console.WriteLine(" 4.學(xué)生成績修改");
? ? ? ? ? ? ? ? ? ? ? ? ? ? Console.WriteLine("學(xué)號固定不變,按照學(xué)號查找");
? ? ? ? ? ? ? ? ? ? ? ? ? ? Console.WriteLine("請輸入學(xué)號:");
? ? ? ? ? ? ? ? ? ? ? ? ? ? string id1 = Console.ReadLine();
? ? ? ? ? ? ? ? ? ? ? ? ? ? AmendStudent(student,id1);
? ? ? ? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? ? ? ? ? case 0:
? ? ? ? ? ? ? ? ? ? ? ? Console.WriteLine(" 0.退出系統(tǒng)");
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? ? ? ? ? default:
? ? ? ? ? ? ? ? ? ? ? ? ? ? Console.WriteLine("您輸入的數(shù)字有誤,請重新輸入(0~4)");
? ? ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ?
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ? ? ? Console.WriteLine();
? ? ? ? ? ? ? ? ? ? Console.WriteLine("******歡迎進入功能菜單欄*******");
? ? ? ? ? ? ? ? ? ? Console.WriteLine("******1.學(xué)生成績輸入*******");
? ? ? ? ? ? ? ? ? ? Console.WriteLine("******2.學(xué)生成績輸出*******");
? ? ? ? ? ? ? ? ? ? Console.WriteLine("******3.學(xué)生成績查詢*******");
? ? ? ? ? ? ? ? ? ? Console.WriteLine("******4.學(xué)生成績修改*******");
? ? ? ? ? ? ? ? ? ? Console.WriteLine("******0.退出系統(tǒng)***********");
? ? ? ? ? ? ? ? ? ? Console.WriteLine("請選擇功能:");
? ? ? ? ? ? ? ? ? ? ? n =int.Parse ( Console.ReadLine());
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ??
? ? ? ? ? ? }
? ? ? ? ? ? ?static void InputStudent(String[,]student ,int num)
? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? int temp;
? ? ? ? ? ? ? ? string strStudent;
? ? ? ? ? ? ? ? string[] strInof;
? ? ? ? ? ? ? ? Console.WriteLine("請輸入學(xué)生信息(以·分隔開):學(xué)號·姓名·語文·數(shù)學(xué)·英語");
? ? ? ? ? ? ? ? for (int i=0;i<num;i++)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? Console.WriteLine("請輸入第{0}個學(xué)生的信息。",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("**********************該學(xué)生的信息***************************");
? ? ? ? ? ? ? ? ? ? Console.WriteLine("|------------------------------------------------------------|");
? ? ? ? ? ? ? ? ? ? Console.WriteLine("| ? 學(xué)號 ?| ?姓名 ?| ?語文 | ?數(shù)學(xué) | ?英語 | ?總分 ?| 平均分 |");
? ? ? ? ? ? ? ? ? ? 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("**********************該學(xué)生的信息***********************");
? ? ? ? ? ? ? ? ? ? ? ? Console.WriteLine("|--------------------------------------------------------|");
? ? ? ? ? ? ? ? ? ? ? ? Console.WriteLine("| ?學(xué)號 ?| 姓名 ?| 語文 | 數(shù)學(xué) | 英語 | 總分 ?| ?平均分 ?|");
? ? ? ? ? ? ? ? ? ? ? ? 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("查詢失敗,您輸入的學(xué)號有誤?。。?!");
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? static void AmendStudent(String[,] student, string id1)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? int i = 0;
? ? ? ? ? ? ? ? for (; i < student.Length; i++)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? if (student[i, 0] == id1)
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ?Console.WriteLine("**************************該學(xué)生的信息**********************");
? ? ? ? ? ? ? ? ? ? ? ? Console.WriteLine("|----------------------------------------------------------|");
? ? ? ? ? ? ? ? ? ? ? ? Console.WriteLine("| 學(xué)號 ?| 姓名 ?| ?語文 | ?數(shù)學(xué) ?| 英語 ?| ?總分 | 平均分 ?|");
? ? ? ? ? ? ? ? ? ? ? ? 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.修改數(shù)學(xué)成績*****");
? ? ? ? ? ? ? ? ? ? ? ? Console.WriteLine("******4.修改英語成績*****");
? ? ? ? ? ? ? ? ? ? ? ? Console.WriteLine("******0.退出修改*********");
? ? ? ? ? ? ? ? ? ? ? ? Console.WriteLine("-------------------------");
? ? ? ? ? ? ? ? ? ? ? ? Console.WriteLine("請輸入要修改的選項(對應(yīng)的序號)");
? ? ? ? ? ? ? ? ? ? ? ? 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("請輸入修改后的數(shù)學(xué):");
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 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("請輸入要修改的選項(對應(yīng)的序號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("**********************修改侯該學(xué)生的信息***********************");
? ? ? ? ? ? ? ? ? ? ? ? ? ? Console.WriteLine("|-------------------------------------------------------------|");
? ? ? ? ? ? ? ? ? ? ? ? ? ? Console.WriteLine("| 學(xué)號 ?| 姓名 ?| ?語文 | ?數(shù)學(xué) ?| 英語 ?| 總分 ?| ? ?平均分 ?|");
? ? ? ? ? ? ? ? ? ? ? ? ? ? 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("查找失敗,您輸入的學(xué)號有誤!?。?);
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? Console.ReadKey();
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ?}
? ? }
}以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
使用 BenchmarkDotNet 對 C# 代碼進行基準測試
這篇文章主要介紹了使用 BenchmarkDotNet 對 C# 代碼進行基準測試,幫助大家更好的理解和學(xué)習(xí)使用c#,感興趣的朋友可以了解下2021-03-03

