C#學(xué)生管理系統(tǒng)課程設(shè)計(jì)報(bào)告_第1頁(yè)
C#學(xué)生管理系統(tǒng)課程設(shè)計(jì)報(bào)告_第2頁(yè)
C#學(xué)生管理系統(tǒng)課程設(shè)計(jì)報(bào)告_第3頁(yè)
C#學(xué)生管理系統(tǒng)課程設(shè)計(jì)報(bào)告_第4頁(yè)
C#學(xué)生管理系統(tǒng)課程設(shè)計(jì)報(bào)告_第5頁(yè)
已閱讀5頁(yè),還剩36頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、C#程序設(shè)計(jì)期末作業(yè)通用學(xué)生信息管理系統(tǒng)計(jì)算機(jī)科學(xué)與工程學(xué)院班級(jí):123456姓名:張三兒學(xué)號(hào):123456782014年5月一、題目分析1、基本功能要求:(1)創(chuàng)建相應(yīng)的成員變量保存學(xué)生基本信息;(2)創(chuàng)建相應(yīng)屬性和索引以實(shí)現(xiàn)對(duì)成員變量訪問的封裝;(3)創(chuàng)建相應(yīng)的方法以實(shí)現(xiàn)對(duì)學(xué)生基本信息的管理;(4)創(chuàng)建相應(yīng)的方法以實(shí)現(xiàn)對(duì)學(xué)生成績(jī)的管理;(5)構(gòu)造函數(shù)和析構(gòu)函數(shù);(6)由學(xué)生類派生出小學(xué)生、中學(xué)生以及大學(xué)生;(7)盡量用上繼承、多態(tài)、重載、覆蓋、接口、抽象類、代理、 事件等知識(shí)。2、設(shè)計(jì)思路:本題目要求學(xué)生設(shè)計(jì)一個(gè)通用學(xué)生信息管理系統(tǒng),能夠分別實(shí)現(xiàn) 對(duì)小學(xué)生、中學(xué)生以及大學(xué)生信息及成績(jī)的管理

2、。定義學(xué)生類Student,在學(xué)生類中定義學(xué)生的公共屬性,比如學(xué)號(hào)、 姓名以及平均分等。由學(xué)生類 Student派生出三個(gè)子類,即小學(xué)生類 xiaoxue 中學(xué)生類zhongxue和大學(xué)生類daxue。再分別在各個(gè)子類 中定義其獨(dú)有屬性,編寫函數(shù)進(jìn)行各種操作,主要包括對(duì)學(xué)生信息的 增、冊(cè)h改、查及顯示全部等操作,以及對(duì)學(xué)生的成績(jī)進(jìn)行管理,主 要是求平均分操作并按從高到低降序排列輸出。本系統(tǒng)采用文件存儲(chǔ)數(shù)據(jù),代碼中有對(duì)應(yīng)的文件操作,能夠?qū)崿F(xiàn)對(duì)輸入的數(shù)據(jù)的保存。二、系統(tǒng)設(shè)計(jì)C:V/indowssystem32cmd.exe2、界面設(shè)計(jì):(1)用戶選擇界面:口C:Win d ows5yste m32

3、cm d. exe書面面面A prnvpBi mJ QCfr-日日力 董生生 告喜£-丁清輸入選擇數(shù)字(2子類界面:C:Wind owssy5tem32cm . exe學(xué)加改除姓示擊翟修瞿顯營(yíng)一 生數(shù)數(shù)蓼P全均系息管理系統(tǒng)!排序請(qǐng)輸入選擇(數(shù)字工-7二(3)增加學(xué)生信息:管 序 自 找排 據(jù)據(jù)查要刀統(tǒng) 羲數(shù)瞽全均家 學(xué)瓠饕示正 小修曹顯竄 入:#-1234567請(qǐng)輸入選擇(數(shù)字L7一工著輸入您需添加的學(xué)生記錄的個(gè)數(shù):Il產(chǎn)輸入第1學(xué)生的信息學(xué)號(hào)22姓名22語(yǔ)文成暴22耦髓22球居已保承請(qǐng)按任意鍵繼續(xù)(4)修改學(xué)生信息:C:Windowssystem32cmd.exe5-顯示全部7.退

4、出系力排序請(qǐng)輸入選擇數(shù)字7) :20下"0 0 64 - 19 8均00 3 6學(xué)i 9 8數(shù)0語(yǔ)109187英00 8 5i 8 8勒 ,號(hào) 評(píng) i完的g明四五瀏學(xué)總李李王息改信修生要 學(xué)人 號(hào)i2 3JW2 學(xué)加膽朋所請(qǐng)加-張,續(xù)成鍵斗 2據(jù)意:9數(shù)任一學(xué)改按C:V/indowssystem32cmd-exe*歡迎進(jìn)入小學(xué)生信息管理 系統(tǒng)!1.增加一據(jù)2-修改數(shù)據(jù)3 .刪除破送4 .塞韋查找5 .顯不全部 6.請(qǐng)輸入選擇數(shù)字學(xué)號(hào)010203語(yǔ)文 100 94 85英語(yǔ) 100 % 87所有學(xué)生信幫覽完畢,按任意鍵繼線!數(shù)學(xué)1009286平均分 100 94 86(5)刪除學(xué)生信息

5、:圖 C:Windowssystem 32 cmd-exeS 123456?迎歡數(shù)數(shù)全 學(xué)加改除姓示手 %統(tǒng)!請(qǐng)輸入選擇數(shù)字ir :3平均分 100 94 86數(shù)學(xué)10092860語(yǔ) £«?英續(xù) 繼 簪工艮00 4 511 9 8 名,的 比HH 辜五利賒,續(xù)信要成鍵 生命襄 *天數(shù)任按 所請(qǐng)03數(shù)學(xué)9286平均分9486姓名 張三 王五語(yǔ)文英語(yǔ)9496858?上按任意鍵繼續(xù)!充 三三一 £ 二 5 管 自.5 三日序 找排生數(shù)數(shù)曾全均系 學(xué)加改除姓示手 甘修囑顯按退 A - * 井一12 3 4 5 6 7 迎歡請(qǐng)輸入選擇數(shù)字1-7:5(6)查找學(xué)生信息:i-7

6、:d平均分94英語(yǔ) 數(shù)學(xué)9692產(chǎn)輸入您要查詢的學(xué) 京號(hào)姓左 刖2張三請(qǐng)按任意鍵續(xù)!C:Window5sy5tem32cmd.exe一 序找 排 矍據(jù)查一貨刀統(tǒng) 數(shù)數(shù)瞽全般系 >墻修盥顯盡一 12 3 4 5 6 7語(yǔ)文 94(7)顯示全部信息:歡迎進(jìn)人小學(xué)弟信息管理系統(tǒng)!1 .增加巍握2 .修改數(shù)據(jù)3 .剛除數(shù)帽4 .強(qiáng)姓名誓找5 .顯示堂部6 .按平均臺(tái)排序 7.斗 于可002003姓全 張二 王五語(yǔ)文9485英語(yǔ)9687數(shù)學(xué)9286平均分9486所有學(xué)生信息瀏覽完畢,按任意鍵繼續(xù)!(8)按平均分排序:,exe3 C:Wi n d oW5system 3 2cm d«

7、71;«* 歡迎進(jìn)?1.生信息管理系統(tǒng)!的寓居2 .修改教據(jù)7.請(qǐng)輸入選擇(數(shù)字工-7=6學(xué)號(hào) 002003004姓名 張三 王五情按任意鍵藉主界面!語(yǔ)文948587英語(yǔ) 96 87 79數(shù)學(xué)928685平均分948683、知識(shí)清單1、定義了相應(yīng)的成員變量來保存學(xué)生的基本信息,如學(xué)號(hào)、姓名、科目成績(jī)等;2、定義了相應(yīng)屬性以來獲取學(xué)生基本信息;Add()、3、定義了相應(yīng)的方法實(shí)現(xiàn)了對(duì)學(xué)生基本信息的管理,如Order。、Delete。等方法實(shí)現(xiàn)對(duì)學(xué)生信息的增刪改查;4、定義了相應(yīng)的方法Order。對(duì)學(xué)生成績(jī)信息進(jìn)行管理;5、定義了構(gòu)造函數(shù)進(jìn)行初始化并且有默認(rèn)的析構(gòu)函數(shù);6、定義學(xué)生類St

8、udent,由Student類派生出三個(gè)子類分別對(duì)小學(xué)生、中學(xué)生、大學(xué)生信息進(jìn)行管理;7、本實(shí)驗(yàn)程序沒有連接數(shù)據(jù)庫(kù),所用數(shù)據(jù)都存在相應(yīng)的文件操作中,有相應(yīng)的方法實(shí)現(xiàn)文件相關(guān)操作;8、重載了操作符小于和大于號(hào)五、實(shí)驗(yàn)程序代碼using Sys tern;using System.IO;using ConsoleApplicationl;public class Student (public string no;public string name;public int average;public static bool operator >(Student s 1, Student s

9、2) / 重載 (if (si.average > s2.average) return true;elsereturn false; )public static bool operator <(Student s 1, Student s2) (if (si.average < s2.average) return true;elsereturn false;class StudentManageSystems ta tic Console Application l.xiaoxue sd; public static void show()int cases = 0;b

10、ool flag = true; while (flag) Console.Clear();Console .WriteLine(Htt*Console.W rite Lin e (HttConsole.W rite Lin e (uttConsole.W rite Lin e (Htt歡迎進(jìn)入學(xué)生信息管理系統(tǒng)!*我*”);1 .小學(xué)生界面”);2 .中學(xué)生界面”);3 .大學(xué)生界面");Console .WriteLine(”tt*");Cons ole .Write (ntt 請(qǐng)輸入選擇(數(shù)字 1-3):”);cases = Convert.ToInt32(Consol

11、e.ReadLine(); if (cases <= 3 &&cases >= 1) flag = folse;switch (cases)case 1:Menu 1(); break;case 2:Menu2(); break;case 3:Menu3(); break;Write I ine *'»/小學(xué)主菜單public static void Menu 1()(xiaoxue s = new xiaoxue();bool Flag = true;int seinumber = 0;while (Flag) Console.Clear();C

12、onsole .Write Line (AN* 林, Console.W rite Lin e (Att Console .Write Line(Att Console .Write Line(Att Console.W rite Lin e (Att Console.W rite Lin e (Att Console .Write Line(Att Console.W rite Lin e (Att Console歡迎進(jìn)入小學(xué)生信息管理系統(tǒng)!杖*卅)1 .增加數(shù)據(jù)”);2 .修改數(shù)據(jù)”);3 .刪除數(shù)據(jù)”);4 .按姓名查找”);5 .顯示全部”);6 .按平均分排序”);7 .退出系統(tǒng)”)

13、;try Console .Write (Htt 請(qǐng)輸入選擇(數(shù)字 1-7):"); seinumber = Convert.ToInt32(Console.ReadLine(); ) catch (FormatException) Console.WriteLine(n你輸入的數(shù)據(jù)格式有誤!H); if (seinumber <= 7 && seinumber >= 1) Flag = false;switch (seinumber) case 1:s.Add();break;case 2:s.ModityO; break; case 3:s.Delet

14、e Da ta();break;case 4:s.Search();break;case 5:s.Browse();break;case 6:s.Order();break;case 7:Environme nt.Exit(O);break;public static void Menu2()/中學(xué)主菜單(zhongxue s = new zhongxue();bool Flag = true;int seinumber = 0; while (Flag) Console.Clear();Console .WriteLine("tt*歡迎進(jìn)入中學(xué)生信息管理系統(tǒng)!杖*林”);Conso

15、le.W rite Lin e (HttConsole.W rite Line1 .增加數(shù)據(jù)”);2 .修改數(shù)據(jù)”);3 .刪除數(shù)據(jù)”);Console.W rite Lin e (nttConsole.W rite Lin e (ntt Console.W rite Lin e (Htt Console.W rite Lin e(ntt Console.W rite Lin e (ntt4 .按姓名查找”);5 .顯示全部”);6 .按平均分排序”);7 .退出系統(tǒng))Cons ole .Write (,rtt 請(qǐng)輸入選擇(數(shù)字 1-7):”); seinumber = Con vert.To

16、in t32(Cons ole.Re adLine(); Console.WriteLine("你輸入的數(shù)據(jù)格式有誤 !n); if (seinumber <= 7 && seinumber >= 1) Flag = false;switch (seinumber) case 1:s.Add2();break;case 2:s.Modify2();break;case 3:s.Delete Data2(); break;case 4:s.Search2();break;case 5:s.Browse2();break;case 6:s.Order2();b

17、reak;case 7:Environment.Exit(O); break;/ 大學(xué)主菜單public static void Menu3()daxue s = new daxue(); bool Flag = true;int seinumber = 0;while (Flag) Console.Clear();Console.W rite Lin e (Htt *Console.W rite Lin e (Htt Console.W rite Lin e (Htt Console.W rite Line(Htt Console.W rite Lin e (Htt Console.W ri

18、te Line(Htt Console.W rite Lin e (Htt Console.W rite Lin e (Htt Console歡迎進(jìn)入大學(xué)生信息管理系統(tǒng)!林*卅)1 .增加數(shù)據(jù)”);2 .修改數(shù)據(jù)”);3 .刪除數(shù)據(jù)”);4 .按姓名查找");5 .顯示全部”);6 .按平均分排序”);7 .退出系統(tǒng)”);Cons ole .Write (Htt.Write Line("11秋*楠*林*秋*);請(qǐng)輸入選擇(數(shù)字1-7):”);seinumber = Con vert.Toin t32(Cons ole.Re adLine();Console.WriteLin

19、e("你輸入的數(shù)據(jù)格式有誤!!”);if (seinumber <= 7 && seinumber >= 1) Flag = fake;switch (seinumber) case 1:s.Add3();break;case 2:s.Modify3();break;case 3:s.Delete Da ta3(); break;case 4:s.Search3();break;case 5:s.Browse3();break;case 6:s.Order3();break;case 7:Environment.Exit(O); break;public

20、static void Save(int n) III 保存 N 個(gè)學(xué)生信息 (File Stream fs = null;Bin ary Writer bw = null;File Info fi = null;Directory In to di = new Directorylnfo(',.n); try (string s = di.Root.ToStringO;/獲取當(dāng)前文件的根目錄s = s + U1 .datn;fi = new Filelnfo(s);if (fi.Exists) 判斷文件是否存在,存在則追加,不存在則創(chuàng)建fs = new FileStream(s, F

21、ile Mode. Append, File Access. Write); bw = new BinaryWriter(fs);) else fs = new FileStream(s, File Mode .Create, File Access. Write); bw = new BinaryWriter(fs);)catch (lOException) Console.WriteLine(u 操作文件失?。?quot;); return;)try (for (int i = 0; i < n; i+) bw.Write(sdi.no); bw.Write(); b

22、w.Write(sdi.english); bw. Write (sdi.Chinese); bw. Write (sdi.math); bw.Write(sdi.a verage);)catch (lOException) Console.WriteLine(u 寫文件失敗!"); return;)finally bw.Close();fs.Close();Cons ole .Write Line("數(shù)據(jù)已保存!請(qǐng)按任意鍵繼續(xù)");Console.ReadKey(true);Menu 1();public static void SaveToArray(ref

23、int len) III 將數(shù)據(jù)保存至數(shù)組中sd = new xiaoxuelen;for (int j = 0; j < len; j+) sdj = new xiaoxue();) try (File Stream fs = null;BinaryReader br = null;Directory In fb di = new DirectoryInfb(,.H);String s = di.Root.ToString(); 獲取當(dāng)前文件的根目錄 s = s + “l(fā).dat”;fs = new FileStream(s, File Mode.Open, File Access.R

24、ead);br = new BinaryReader(fs);int i = 0;try for (i = 0; i < len; i+)sdi.no = br.ReadString(); = br.ReadString();sdi.english = br.ReadInt32();sdi.Chinese = br.ReadInt32();sdi.math = br.ReadInt32();sdi. a verage = br.ReadInt32();)catch (EndOtStreamException)len = i - 1; finally br.Close();

25、fs.Close();)catch return;public static void SaveToFile(int len)/將數(shù)據(jù)保存至文件中(File Stream fs 1 = null;Bin ary Writer bw = null;Directorylnfb di;string s;try (di = new Directorylnfo(u.u);s = di.Root.ToStringO; /獲取當(dāng)前文件的根目錄s = s + "1 .dat”;fs 1 = new FileStream(s, File Mode.Create, File Access. Write)

26、;bw = new BinaryWriter(fs 1);for (int i = 0; i < len; i+) if(sdi.no != "")bw.Write(sdi.no);bw.Write();bw.Write (s di.e nglis h);bw.Write(sdi.chinese);bw.Write (sdi.ma th);b w. Write (sdi.a verage);catch (lOException) Console.WriteLine("寫入數(shù)據(jù)錯(cuò)誤!");Console.ReadKey(true);r

27、eturn;finally bw.Close();fs l.Close();Console.WriteLine(n 修改數(shù)據(jù)成功 !”);Console.WriteLine("請(qǐng)按任意鍵繼續(xù)!");Console.ReadKey(true);主函數(shù)Menu 1();public static void Main() show();Menu 1();using Sys tern;using System.Collections.Generic;using System.Linq;using System.IO;using System.Text;namespace Conso

28、le Application1class xiaoxue:Student (static ConsoleApplicationl .xiaoxue sd;public int Chinese;public int english;public int math; public int getchinese (get return Chinese; set Chinese = value; ) public int getenglish (get return english; set english = value; ) public int getmath (get return math;

29、) set math = value; )pubUc void Input(int i) 輸入某一學(xué)生信息 / Console.WriteLineC'n 請(qǐng)輸入第0學(xué)生的信息:”,i + 1); while (true)/這個(gè)循環(huán)用來控制學(xué)號(hào)不能相同( Console.Write(nn 學(xué)號(hào)”); sdi.no = Console.ReadLine(); int j = 0; for(j = O;j<i; j+) if (sdi.no != sdj.no) break; ) ) if(i =0 II j != i) break;Console.WriteLine("您輸

30、入的學(xué)號(hào)重復(fù),請(qǐng)重輸!”);) Cons ole .Write (n 姓名"); = Console.ReadLine(); try (Console.Write(n語(yǔ)文成績(jī)”);sdi.english = Convert.ToInt32(Console.ReadLine();Console .Write (H英語(yǔ)成績(jī)”);sdi.chinese = Convert.ToInt32(Console.ReadLine();Console .Write (H數(shù)學(xué)成績(jī)”);sdi.math = Convert.ToInt32(Console.ReadLine();sdi.

31、average = (sdi.english + sdi.chinese + sdi.math) / 3; ) catch (FormatException e) Console .Write Line (0 您輸入的數(shù)據(jù)有誤!" + e.Message);public static void SaveToArray(ref int len) ./ 將數(shù)據(jù)保存至數(shù)組中public static void Save(int n) ./保存 N 個(gè)學(xué)生信息public static void SaveToFile(int len) Menu 1(); / 將數(shù)據(jù)保存至文件中 privat

32、e static void Menu 1() public void Add()/添加模塊( int n = 0;try Console.WritcLineCn請(qǐng)輸入您需添加的學(xué)生記錄的個(gè)數(shù):");n = Convert.ToInt32(Console.ReadLine();) catch (FormatException) Console.WriteLine(n您輸入的數(shù)據(jù)格式有誤!”);) sd = new xiaoxuen; for (int i = 0; i < n; i+)sdi = new xiaoxue(); ) fbr (int i = 0; i < n;

33、 i+)Input(i); ) if(n != 0)Save(n); elseMenu 1(); )public void ModifyO/修改模塊int len = 0;Brows eAll(reflen);S a veToArra y(re f len);xiaoxue temp = new xiaoxue();try (Console .Write Line("請(qǐng)輸入要修改學(xué)生的學(xué)號(hào)(學(xué)號(hào)不可改):"); temp.no = Console.ReadLine();Console .Write (An 姓名:"); = Console.Rea

34、dLine();Console .Write (nn 語(yǔ)文:”);temp.english = Convert.ToInt32(Console.ReadLine();Console .Write (nn 英語(yǔ)temp.Chinese = Convert.ToInt32(Console.ReadLine();Console .Write (*'n 數(shù)學(xué)temp. ma th = Convert.ToInt32(Console.ReadLine();temp.average = (temp.Chinese + temp.math + temp.english) / 3;)catch (Fo

35、rmatException) Console .WriteLine。輸入數(shù)據(jù)格式有誤!”);return;bool Flag = false;for (int i = 0; i < len; i+) if (sdi.no = temp.no) sdi = temp;Flag = true;)if (Flag) SaveToFile(len);)else Console .Write Line("未能查到信息!請(qǐng)重試! ");Console .Write Line (n 請(qǐng)按任意鍵繼續(xù)!");Console.ReadKey(true);Menul();publ

36、ic void DeleteData()/刪除信息(int len = 0;Browse All(reflen);SaveTo Arra y(ref len);Console.WriteCt請(qǐng)輸入您要?jiǎng)h除的學(xué)生的學(xué)號(hào):”);String s = Console.ReadLine(); bool flag = folse;for (int i = 0; i < len; i+)if (sdi.no = s) flag = true;sdi.no = ,n,; = sdi.english = 0; sdi.chinese = 0; sdi.math = 0;sdi. a v

37、erage = 0; ) ) SaveToFile(len);if (!«ag) Console.WriteLine(H沒有此人信息!無法刪除!”); Console.WriteLine(n 請(qǐng)按任意鍵繼續(xù)!");Console.ReadKey(true);Menu 1(); )public void Search()/查找模塊(Cons ole .Write (n請(qǐng)輸入您要查詢的學(xué)生的姓名:”);String s = Console.ReadLine();int len = 80;S a veToArra y(re f len);Cons ole .Write Line

38、(Hn 學(xué)號(hào) 姓名語(yǔ)文英語(yǔ)數(shù)學(xué)平均分”);bool flag = folse;for (int i = 0; i < len; i+) if(sdi.no = ,n) break;if ( = s) flag = true;Cons ole .Write ("0,-10H, sdi.no);Console.Write("0,-10)*', );Cons ole .Write ("0,-10 H, sdi.english);Console.Write("0,-12", sdi.chinese);Con

39、sole.Write("0,-12)*', sdi.math);Console .Write(n0,-l 2 *', sdi.average);Console.Write Line();if (!«ag) Console .Write Line("沒有查到此人信息!");) Console.WriteLine(n 請(qǐng)按任意鍵繼續(xù)!”);Console.ReadKey(true);Menu 1(); )public void Browse()/瀏覽模塊(int i = 0;Brows eAll(refi);Menu 1(); )public

40、 void Browse All(ref int len)/瀏覽所有數(shù)據(jù)(len = 0;File Stream fs = null;BinaryReader br = null;File Into fi = null;Directory Info di = new DirectoryInfb(H.H); try ( string s = di.Root.ToString();獲取當(dāng)前文件的根目錄s = s + "1 .datn;fi = new Filelnfb(s);if (fi.Exists) /判斷文件是否存在fs = new FileStream(s, File Mode.

41、Open, File Access.Read); br = new BinaryReader(fs);英語(yǔ)Console.WriteLine("n 學(xué)號(hào)姓名語(yǔ)文數(shù)學(xué)平均分)try ( while (true) Cons ole. Write (*'0,-1 Of, br.ReadStringO); Console.Write("0,-10", br.ReadStringO);Console.Write(n0,-10n, br.ReadInt32();Console.Write(H0,-12)n, br.ReadInt32();Console.Write(n

42、0,-12n, br.ReadInt32();Console.Write(n0,-12)n, br.ReadInt32(); Console.Write Line(); le n = le n + 1;catch (EndOfStreamException) Console.WriteLine(n所有學(xué)生信息瀏覽完畢,按任意鍵繼續(xù)!”);br.Close();fs.Close();Console.ReadKey(true);)else Console.WriteLine("n 沒有學(xué)生數(shù)據(jù)文件!”);return;)catch (lOException) Console.WriteL

43、ine(n 操作文件失??!");return;public void Order()/ 排序模塊(int len = 80;SaveToArray(ref len); /按平均分進(jìn)行降序排列 xiaoxue temp = new xiaoxue();fbr (int i = 0; i < len; i+) for (int j = 0; j < len - i - 1; j+) if(sdU<sdU+ 1) temp = sdj;sdj = sdj + 1;sdj + 1 = temp;英語(yǔ)數(shù)學(xué)Cons ole. Write Line (nn學(xué)號(hào) 姓名語(yǔ)文平均分”)

44、;fbr (int i = 0; i < len; i+) Console .Write (n0,-l Of, sdi.no);Console .Write0", );Console .Write (n0,-10)", sdi.english);Console .Write(n0,-12", sdi.chinese);Console .Write (n0,-12", sdi.math);Console .Write(H0,-12", sdi.a verage);Console .Write Line();Console.W

45、riteLine(u請(qǐng)按任意鍵返回主界面!”);Console.ReadKey(true);Menu 1();using System;using System.Collections.Generic;using System.Linq;using System.IO;using System.Text;namespace Console Application1 (class zhongxue:Student (s ta tic Console Application 1 .zhongxue sd;public int phys ics;public int chemistry;public

46、 int biology;public int getphysics (get return physics;) set physics = value;) )public int getchemistry (get return chemistry; set chemistry = value; )public int getbiology (get return biology; set biology = value;)public void Input(int i) / 輸入某一學(xué)生信息 Console.WriteLine(Hn 請(qǐng)輸入第0學(xué)生的信息 二 i+ 1); while (t

47、rue) 學(xué)號(hào)不能相同Console.WriteC'Xn學(xué)號(hào)”);sdi.no = Console.ReadLine(); int j = 0; for(j = O;j< i; j+) if (sdi.no != sdj.no) break;if(i =0 II j != i)break;Console.WriteLine(n您輸入的學(xué)號(hào)重復(fù),請(qǐng)重輸! ”);fbr (int i = 0; i < n; i+) Cons ole .Write ('*姓名”); = Console.ReadLine();try Console .Write (H物理成

48、績(jī)”);sdi.physics = Convert.ToInt32(Console.ReadLine();Console .Write (H化學(xué)成績(jī)”);sdi.chemistry = Convert.ToInt32(Console.ReadLine();Console .Write (n生物成績(jī)”);sdi.biology = Convert.ToInt32(Console.ReadLine();sdi.average = (sdi.physics + sdi.chemistry + sdi.biology) / 3; )catch (FormatException e) Console .

49、Write Line ("您輸入的數(shù)據(jù)有誤!" + e.Message);public s ta tic void SaveToArray(ref int len) ./數(shù)據(jù)保存至數(shù)組中public static void Save(int n) ./保存 N 個(gè)學(xué)生信息public static void SaveToFile(int len) Menu2(); III 數(shù)據(jù)保存至文件中 private static void Menu2() public void Add2()/添加信息int n = 0;try Console.WritcLine(、n請(qǐng)輸入您需添加的

50、學(xué)生記錄的個(gè)數(shù):");n = Convert.ToInt32(Console.ReadLine();)catch (FormatException) Console .Write Line。您輸入的數(shù)據(jù)格式有誤!”);)sd = new zhongxuen;fbr (int i = 0; i < n; i+) sdi = new zhongxue();Input(i);if(n != 0) Save(n);else Menu2(); )public void Modity2() /修改信息 (int len = 0;Brows eAll(reflen);S a veToArra

51、 y(re f len);zhongxue temp = new zhongxue(); try Console.WriteLine("請(qǐng)輸入要修改學(xué)生的學(xué)號(hào)(學(xué)號(hào)不可改):"); temp.no = Console.ReadLine();Console .Write (An 姓名:"); = Console.ReadLine();Console.Write(nn 物理:”);temp.physics = Convert.ToInt32(Console.ReadLine();Console .Write (An 化學(xué):”);temp.chemis

52、try = Convert.ToInt32(Console.ReadLine();Console.Write(nn 生物:”);temp.bio logy = Convert.ToInt32(Console.ReadLine(); temp.ave rage = (temp.physics + temp.chemis try + temp.bio logy) / 3;) catch (FormatException) Console.WriteLine(n輸入數(shù)據(jù)格式有誤!"); return; ) bool Flag = false; fbr (int i = 0; i < len; i+) if (sdi.no =

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論