C程序設(shè)計(jì)試驗(yàn)報(bào)告_第1頁
C程序設(shè)計(jì)試驗(yàn)報(bào)告_第2頁
C程序設(shè)計(jì)試驗(yàn)報(bào)告_第3頁
C程序設(shè)計(jì)試驗(yàn)報(bào)告_第4頁
C程序設(shè)計(jì)試驗(yàn)報(bào)告_第5頁
已閱讀5頁,還剩34頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

1、金隈科技號(hào)院學(xué)生實(shí)驗(yàn)報(bào)告(理工類)課程名稱:C#程序設(shè)計(jì)專業(yè)班級(jí):M1計(jì)算機(jī)科學(xué)與技術(shù)(專轉(zhuǎn)本)學(xué)生學(xué)號(hào): XXXXXXXX 學(xué)生姓名:XXX所屬院部:信息技術(shù)學(xué)院 指導(dǎo)教師:XXX2012 2013學(xué)年第二 學(xué)期金陵科技學(xué)院教務(wù)處制實(shí)驗(yàn)報(bào)告書寫要求實(shí)驗(yàn)報(bào)告原則上要求學(xué)生手寫,要求書寫工整。若因課程特點(diǎn)需打印的,標(biāo)題采用四號(hào)黑體,正文采用小四號(hào)宋體,單倍行距。紙張一律采用A4的紙張。實(shí)驗(yàn)報(bào)告書寫說明實(shí)驗(yàn)報(bào)告中實(shí)驗(yàn)?zāi)康暮鸵蟆?shí)驗(yàn)儀器和設(shè)備、實(shí)驗(yàn)內(nèi)容與過程、實(shí)驗(yàn)結(jié)果與分析這四項(xiàng)內(nèi)容為必需項(xiàng)。教師可根據(jù)學(xué)科特點(diǎn)和實(shí)驗(yàn)具體要求增加項(xiàng)目。填寫注意事項(xiàng)( 1)細(xì)致觀察,及時(shí)、準(zhǔn)確、如實(shí)記錄。( 2)準(zhǔn)確

2、說明,層次清晰。( 3)盡量采用專用術(shù)語來說明事物。( 4)外文、符號(hào)、公式要準(zhǔn)確,應(yīng)使用統(tǒng)一規(guī)定的名詞和符號(hào)。( 5)應(yīng)獨(dú)立完成實(shí)驗(yàn)報(bào)告的書寫,嚴(yán)禁抄襲、復(fù)印,一經(jīng)發(fā)現(xiàn),以零分論處。實(shí)驗(yàn)報(bào)告批改說明實(shí)驗(yàn)報(bào)告的批改要及時(shí)、認(rèn)真、仔細(xì),一律用紅色筆批改。實(shí)驗(yàn)報(bào)告的批改成績(jī)采用五級(jí)記分制或百分制,按 金陵科技學(xué)院課堂教學(xué)實(shí)施細(xì)則中作業(yè)批閱成績(jī)?cè)u(píng)定要求執(zhí)行。實(shí)驗(yàn)報(bào)告裝訂要求實(shí)驗(yàn)批改完畢后,任課老師將每門課程的每個(gè)實(shí)驗(yàn)項(xiàng)目的實(shí)驗(yàn)報(bào)告以自然班為單位、按學(xué)號(hào)升序排列,裝訂成冊(cè),并附上一份該門課程的實(shí)驗(yàn)大綱。金陵科技學(xué)院實(shí)驗(yàn)報(bào)告實(shí)驗(yàn)項(xiàng)目名稱: C罐礎(chǔ)編程實(shí)驗(yàn)學(xué)時(shí):6同組學(xué)生姓名: 實(shí)驗(yàn)地點(diǎn):A205實(shí)驗(yàn)日期

3、:9月17日-9月24日 實(shí)驗(yàn)成績(jī): 批改教師:批改時(shí)間:金陵科技學(xué)院實(shí)驗(yàn)報(bào)告實(shí)驗(yàn)1 C#基礎(chǔ)編程一、實(shí)驗(yàn)?zāi)康?、熟悉 Visual Studio .NET 開發(fā)環(huán)境;2、掌握C#應(yīng)用程序的基本操作過程;3、掌握C#的數(shù)據(jù)類型,運(yùn)算符以及表達(dá)式的使用;4、掌握分支和循環(huán)語句的使用方法;5、掌握一維數(shù)組,二維數(shù)組及數(shù)組型數(shù)組的使用。二、實(shí)驗(yàn)要求(1)編寫程序要規(guī)范、正確,上機(jī)調(diào)試過程和結(jié)果要有記錄;(2)做完實(shí)驗(yàn)后給出本實(shí)驗(yàn)的實(shí)驗(yàn)報(bào)告。三、實(shí)驗(yàn)設(shè)備、環(huán)境安裝有 Visual Studio .NET 軟件。四、實(shí)驗(yàn)步驟1、分析題意;2、根據(jù)題目要求,新建項(xiàng)目;3、編寫并輸入相關(guān)的程序代碼;5、運(yùn)行

4、與調(diào)試項(xiàng)目;6、保存項(xiàng)目。五、實(shí)驗(yàn)內(nèi)容1、編寫一個(gè)簡(jiǎn)單的控制臺(tái)應(yīng)用程序,打印一行文字(如你的姓名)。using System;using System.Collections.Generic;using System.Text;namespaceTest1_1classProgramstatic void Main( string 口 args)Console.WriteLine( "1121412016 張明星!”);Console.ReadLine();2、編寫一個(gè)簡(jiǎn)單的Windows應(yīng)用程序,在標(biāo)簽中顯示你的姓名。Form窗體的代碼:using System;using Sys

5、tem.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace w_1public partial class Forml : Formpublic Form1()InitializeComponent();private void button1_Click( object sender, EventArgs e)label2.Text ="你輸入的姓名:&

6、quot;+textBox1.Text;textBox2.Text ="你輸入的姓名:"+ textBox1.Text;MessageBoxShow("你輸入的姓名:"+ textBox1.Text);3、編寫一個(gè)一個(gè)程序,用來判斷輸入的是大寫字母,小寫字母,數(shù)字還是其他的字符。using System;using System.Collections.Generic;using System.Text;namespace Testclass Programstatic void Main( string 口 args)char c;int i=0;wh

7、ile (i < 10)Console .WriteLine("請(qǐng)輸入一個(gè)字符:");c =Convert .ToChar( Console .ReadLine();i+;if ( char .IsUpper(c)26Console .WriteLine(c +"這是一個(gè)大寫字母");else if ( char .IsLower(c)Console .WriteLine(c +"這是一個(gè)小寫字母");else if ( char .IsDigit(c)Console .WriteLine(c +"這是一個(gè)數(shù)字&quo

8、t;);elseConsole .WriteLine(c +"什么也不是!");Console .ReadLine();4、分別用 while, do-while, for循環(huán)求1到100的和。using System;using System.Collections.Generic;using System.Text;namespace Testclass Programstatic void Main( string 口 args) int sum = 0, i = 0;for (i = 1; i <= 10; i+)sum = sum + i;dosum = s

9、um + i;i+; while (i <= 10);while (i <= 10)sum = sum + i;i+;Console .WriteLine( "1 到的和為"+ sum);Console .ReadLine();5、定義一個(gè)一維數(shù)組,用隨機(jī)數(shù)為此賦值,用 foreach循環(huán)輸出其中的內(nèi)容。using System;using System.Collections.Generic;using System.Text;namespaceTest1_1classProgramstatic void Main( string 口 args) int口 a

10、 = new int10;Random ran = new Random();for(int i=0;i<10;i+)ai=ran.Next(100);foreach(int i in a) Console.WriteLine(i+ "");6、實(shí)現(xiàn)二維數(shù)組的輸入和輸出。using System;using System.Collections.Generic;using System.Text;namespace Testclass Programstatic void Main( string 口 args)/輸出100里的十個(gè)隨機(jī)數(shù)int a = new int

11、 10;int , a = new int 3, 3;for (int i = 0; i < 3; i+)for ( int j = 0; j < 3; j+)ai, j =Convert .ToInt32( Console .ReadLine();for ( int i = 0; i < 3; i+)for ( int j = 0; j < 3; j+)Console .Write(ai, j +"");Console .Write( "n");7、實(shí)現(xiàn)數(shù)組型數(shù)組的輸入和輸出。using System;using System.

12、Collections.Generic;using System.Text;namespaceTest1_1classProgramstatic void Main( string 口 args)int口口 a = new int2;a0 = new int3 Convert.ToInt32(Console.ReadLine(), Convert .ToInt32( Console.ReadLine(), Convert .ToInt32( Console.ReadLine() ;a1 = new int4 Convert.ToInt32(Console.ReadLine(), Convert

13、 .ToInt32( Console.ReadLine(), Convert .ToInt32( Console.ReadLine(), Convert.ToInt32( Console.ReadLine() ;for (int j = 0; j <3; j+)Console.Write(a0j+ "");Console.WriteLine( "n");for (int j = 0; j < 4; j+)Console.Write(a1j + "");六、實(shí)驗(yàn)體會(huì)(遇到問題及解決辦法,編程后的心得體會(huì))實(shí)驗(yàn)項(xiàng)目名稱:類與對(duì)

14、象實(shí)驗(yàn)學(xué)時(shí):6同組學(xué)生姓名:實(shí)驗(yàn)地點(diǎn):A205實(shí)驗(yàn)日期:9月24日-10月1日實(shí)驗(yàn)成績(jī):批改教師:批改時(shí)間:實(shí)驗(yàn)2類與對(duì)象一、實(shí)驗(yàn)?zāi)康?、要?1)掌握類的定義和使用;(2)掌握類的數(shù)據(jù)成員,屬性的定義和使用;(3)掌握方法的定義,調(diào)用和重載以及方法參數(shù)的傳遞;(4)掌握構(gòu)造函數(shù)的定義和使用。二、實(shí)驗(yàn)要求(1)編寫程序要規(guī)范、正確,上機(jī)調(diào)試過程和結(jié)果要有記錄;(2)做完實(shí)驗(yàn)后給出本實(shí)驗(yàn)的實(shí)驗(yàn)報(bào)告。三、實(shí)驗(yàn)設(shè)備、環(huán)境安裝有 Visual Studio .NET 軟件。四、實(shí)驗(yàn)步驟1、分析題意;2、根據(jù)題目要求,新建項(xiàng)目;3、編寫并輸入相關(guān)的程序代碼;5、運(yùn)行與調(diào)試項(xiàng)目;6、保存項(xiàng)目。五、實(shí)驗(yàn)內(nèi)容1

15、、定義一個(gè)方法,實(shí)現(xiàn)兩個(gè)數(shù)的交換(分別把參數(shù)按值傳遞和按引用傳遞)Form里面的代碼:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespaceTest1_1public partial classForm1 : Formpublic Form1()InitializeComponent();private void bt

16、nSwap_Click( object sender, EventArgs e)Swaper s = new Swaper();int a = Convert.ToInt32(txtOne.Text);int b = Convert.ToInt32(txtTwo.Text);IblShow.Text = s.Swap(a,b);,a,b);IblShow.Text += string.Format("nn 主調(diào)方法:條用之后:a=0,b=1"txtOne.Text = a.ToString();txtTwo.Text = b.ToString();classSwaperpu

17、blic string Swap(int x, int y)int temp;temp = x;x = y;y = temp;return string.Format("被調(diào)方法:交換之后:x0=,y=1" ,x,y);2、定義一個(gè)方法,實(shí)現(xiàn)數(shù)組的排序;using System;using System.Collections.Generic;using System.Text;namespaceTest1_1classProgramstatic void Main( string 口 args) SortLS s = new SortLS();int b = new in

18、t 5;for (int i = 0; i < 5; i+)bi = Convert.ToInt32( Console.ReadLine();s.SortL(b);Console.ReadLine(); classSortLSpublic void SortL(int 口 a) for (int i = 1; i <a.Length; i+)int temp;if (ai-1 < ai) temp = ai-1;ai-1 = ai;ai = temp;for (int i = 0; i < a.Length; i+) Console.Write(ai+ "&q

19、uot;);3、定義一個(gè)學(xué)生類,把學(xué)生類當(dāng)作對(duì)象來傳遞;using System;using System.Collections.Generic;using System.Text;namespaceTest1_2classProgramstatic void Main( string 口 args)Student stu = new Student(); ="張三"stu.age = 20;stu.ShowMessage(stu);public classStudentpublic string name;public int age;public vo

20、id ShowMessage(Student student) Console.WriteLine("學(xué)生姓名:"++" " +"年齡:"+student.age); 4、定義一個(gè)方法,求兩個(gè)數(shù)的和和差,通過參數(shù)把這兩個(gè)值帶回;using System;using System.Collections.Generic;using System.Text;namespaceTest1_3classProgramstatic void Main( string 口 args)A ax = new A();int a

21、, b;a = 10;b = 3;ax.Method(a,b); classA public void Method( int x, int y)int add, miu;add = x + y;miu = x - y;Console.WriteLine("兩數(shù)之和:"+ add + "n" + "兩數(shù)之差:"+ miu);5、用構(gòu)造函數(shù)重載,實(shí)現(xiàn)矩形的面積,圓的面積,梯形的面積;using System;using System.Collections.Generic;using System.Text;namespaceTest1

22、_4classProgramstatic void Main( string 口 args) int a = 4;int b = 5;int c = 6;Area al = newArea(a);Area a2 = new Area(a,b);Area a3 = new Area(a,b,c); classAreaint x, y, z;public Area(int a)Console.WriteLine("圓的面積:"+ 3.12 * a*a); public Area(int a,int b) Console.WriteLine("矩形的面積:"+

23、 a*b);public Area(int a,int b,int h)Console.WriteLine("梯形的面積:"+ (a+b)*h/2);6、設(shè)計(jì)一個(gè) windows應(yīng)用程序,在該程序中定義一個(gè)學(xué)生類和班級(jí)類,以處理每個(gè)學(xué) 生的學(xué)號(hào),姓名,語文,數(shù)學(xué)和英語成績(jī),要求:1)能查詢每個(gè)學(xué)生的總成績(jī)。2)能顯示全班前三名的名單。3)能顯示單科成績(jī)最高分和不及格的學(xué)生名單。4)能統(tǒng)計(jì)全班學(xué)生的平均成績(jī)。5)能顯示各科成績(jī)不同分?jǐn)?shù)段的學(xué)生人數(shù)的百分比。Student 類:using System;using System.Collections.Generic;using

24、 System.Text;namespace Test4_3 public class Student public string stuNo;public string name;public double chinese;public double math;public double english;public double sumScoreget return chinese + math + english; StudentList 類:using System;using System.Collections.Generic;using System.Text;namespace

25、 Test4_3public class StudentList : Studentint snums;public Student stu= new Student 50;public StudentList()snums = 0;public void addstu( Student s)stusnums = s;snums+;public int searchstu( string name)int i;for (i = 0; i < snums; i+)if ( = name) break ;if (i = snums) return -1;else retur

26、n i;給所有成績(jī)排序,用后面實(shí)現(xiàn)前三名的排名public void ProThree()for ( int i = 0; i < snums; i+)int k = i;for ( int j = i + 1; j < snums; j+)if (stuj.sumScore > stuk.sumScore) k = j; if (k != i)Student temp;temp = stuk;stuk = stui;stui = temp;/顯本單科成績(jī)的最高分public int HighScore( int k)int p = 0;if (k = 0)for ( int

27、 i = 1; i < snums; i+)if (stui.math > stup.math) p = i;else if (k = 1)for ( int i = 1; i < snums; i+)if (stui.chinese > stup.chinese) p = i;elsefor ( int i = 1; i < snums; i+)if (stui.chinese > stup.chinese) p = i;return p;/顯示不及格名單public string BuhgName(int k)string name="&quo

28、t;if (k = 0)for ( int i = 0; i < snums; i+)if (stui.math < 60) name +=+"n"else if (k = 1)for ( int i = 0; i < snums; i+)if (stui.chinese < 60) name += +"nelsefor ( int i = 0; i < snums; i+)if (stui.english < 60) name += +"nreturn nam

29、e;public string getHL()string Maxer = " " , Loser =""Maxer +="單科數(shù)學(xué)最高:"+ stuHighScore(0).name +"n"Maxer +="單科語文最高:"+ stuHighScore(1).name +"nMaxer +="單科英語最高:"+ stuHighScore(2).name +"nLoser +="單科數(shù)學(xué)掛科名單:"+BuhgName(0) + &qu

30、ot;n"Loser +="單科語文掛科名單:"+ BuhgName(1) + "n"Loser +="單科英語掛科名單:"+ BuhgName(2) + "n"return Maxer + "n" + Loser;/全班的平均成績(jī)public string SumScore()double sum = 0;double avg=0;for ( int i = 0; i < snums; i+)sum = sum + stui.sumScore;avg = sum / snums

31、;return "班級(jí)總分平均分:"+avg;/各科成績(jī)不同分?jǐn)?shù)段的學(xué)生百分比/英語成績(jī)各分?jǐn)?shù)段百分比public string PerC()double per1, per2, per3, per4, per5;double sumC1 = 0, sumC2 = 0, sumC3 = 0, sumC4 = 0, sumC5 = 0;for ( int i = 0; i < snums; i+)if (stui.chinese > 90) && (stui.chinese <= 100) sumC1+;else if (80 <= s

32、tui.chinese) && (stui.chinese < 90)sumC2+;else if (70<=stui.chinese)&& (stui.chinese < 80)sumC3+;else if (60<=stui.chinese)&&(stui.chinese < 70)sumC4+; elsesumC5+;per1 = sumC1 / snums;per2 = sumC2 / snums;per3 = sumC3 / snums;per4 = sumC4 / snums;per5 = sumC5 /

33、 snums;return "語文成績(jī)百分比:"+"n" +"90100:" +per1 + " 8090:" +per2+" 8070:" +per3+"7060:" +per4+" 60 以下的:"+per5;/數(shù)學(xué)成績(jī)各分?jǐn)?shù)段百分比public string PerM()double perl, per2, per3, per4, per5;double sumC1 = 0, sumC2 = 0, sumC3 = 0, sumC4 = 0, sumC

34、5 = 0;for ( int i = 0; i < snums; i+)if (stui.math> 90) &&(stui.math <= 100) sumC1+;else if (80 <= stui.math) && (stui.math < 90) sumC2+;else if (70 <= stui.math) && (stui.math < 80)sumC3+;else if (60 <= stui.math) && (stui.math < 70) sumC4+

35、; else sumC5+;per1 = sumC1 / snums;per2 = sumC2 / snums;per3 = sumC3 / snums;per4 = sumC4 / snums;per5 = sumC5 / snums;return string .Format("數(shù)學(xué)成績(jī)百分比:"+ "n" + "90100:" + per1 + " 8090:"+ per2+ " 8070:"+ per3 +" 7060:"+ per4 +" 60 以下的:&

36、quot;+ per5);/英語成績(jī)各分?jǐn)?shù)段百分比public string PerE()double perl, per2, per3, per4, per5; double sumCI = 0, sumC2 = 0, sumC3 = 0, sumC4 = 0, sumC5 = 0;for ( int i = 0; i < snums; i+)if (stui.english > 90) && (stui.english <= 100)sumC1+;else if (80 <= stui.english) && (stui.englis

37、h < 90)sumC2+;else if (70 <= stui.english) && (stui.english < 80)sumC3+;else if (60 <= stui.english) && (stui.english < 70)sumC4+; else sumC5+;per1 = sumC1 / snums;per2 = sumC2 / snums;per3 = sumC3 / snums;per4 = sumC4 / snums;per5 = sumC5 / snums;return string .Format

38、("數(shù)學(xué)成績(jī)百分比:"+ "n" + "90100:" + per1 + " 8090:"+ per2+ " 8070:"+ per3 +" 7060:"+ per4 +" 60 以下的:"+ per5);From窗體代碼:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using

39、 System.Text;using System.Windows.Forms;namespace Test4_3public partial class Forml : Form public Form1() InitializeComponent();public StudentList sl = new StudentList (); private void btnAdd_Click( object sender, EventArgs e) Student s = new Student ();s.stuNo = txtStuNo.Text; = txtName.Text;

40、s.chinese =Convert .ToDouble(txtChina.Text);s.math =Convert .ToDouble(txtMath.Text);s.english =Convert .ToDouble(txtEng.Text);sl.addstu(s);MessageBoxShow("添加成功"); private void btnSearch_Click( object sender, EventArgs e) int pos = sl.searchstu( this .textBox1.Text); if (pos != -1)label7.Te

41、xt =this .textBox1.Text +”的總成績(jī):"+ sl.stupos.sumScore;else MessageBoxShow("不存在這個(gè)人!"); private void btnFinish_Click( object sender, EventArgs e) label7.Text ="前 3名:"+"n"for ( int i = 0; i < 3; i+)sl.ProThree();label7.Text+= +"n" label7.Text +

42、= sl.getHL()+"n"label7.Text +=Convert .ToString(sl.SumScore()+ "n"label7.Text += sl.PerC()+"n"label7.Text += sl.PerM()+"n"label7.Text += sl.PerE()+"n" 六、實(shí)驗(yàn)體會(huì)(遇到問題及解決辦法,編程后的心得體會(huì))實(shí)驗(yàn)項(xiàng)目名稱:繼承與多態(tài)實(shí)驗(yàn)學(xué)時(shí):6同組學(xué)生姓名: 實(shí)驗(yàn)地點(diǎn):A205實(shí)驗(yàn)日期:10月8日-10月15日 實(shí)驗(yàn)成績(jī):批改教師:批改時(shí)間:實(shí)驗(yàn)3繼承

43、與多態(tài)一、實(shí)驗(yàn)?zāi)康?1)理解類的繼承性與多態(tài)性;(2)掌握虛方法的定義以及如何用虛方法實(shí)現(xiàn)多態(tài);(3)掌握抽象類的定義以及如何用用抽象方法實(shí)現(xiàn)多態(tài);二、實(shí)驗(yàn)要求(1)編寫程序要規(guī)范、正確,上機(jī)調(diào)試過程和結(jié)果要有記錄;(2)做完實(shí)驗(yàn)后給出本實(shí)驗(yàn)的實(shí)驗(yàn)報(bào)告。三、實(shí)驗(yàn)設(shè)備、環(huán)境安裝有 Visual Studio .NET 軟件。四、實(shí)驗(yàn)步驟1、分析題意;2、根據(jù)題目要求,新建項(xiàng)目;3、編寫并輸入相關(guān)的程序代碼;5、運(yùn)行與調(diào)試項(xiàng)目;6、保存項(xiàng)目。五、實(shí)驗(yàn)內(nèi)容1、設(shè)計(jì)一個(gè) Windows應(yīng)用程序,在該程序中首先構(gòu)造一個(gè)學(xué)生基本類,再分別構(gòu)造小 學(xué)生、中學(xué)生、大學(xué)生派生類,當(dāng)輸入相關(guān)數(shù)據(jù),單擊不用的按鈕時(shí)

44、,將分別創(chuàng)建不同的學(xué) 生類對(duì)象,并輸出當(dāng)前學(xué)生的總?cè)藬?shù),該學(xué)生的姓名,學(xué)生類型,平均成績(jī)。Student 類:using System;using System.Collections.Generic;using System.Text;namespaceTest5_1public abstract classStudentprotected string name;protected int age;public static int number;public Student(string name,int age) = name;this.age = age;numbe

45、r+;public string Nameget return name; public abstract double Average();public classPupil : Studentprotected double chinese;protected double math;public Pupil( string name,int age, double chinese, double math):basename, age)this.chinese = chinese;this.math = math;public override double Average。return

46、 (chinese + math) / 2;public classMiddle : Studentprotected double chinese;protected double math;protected double english;public Middle( string name, int age,double chinese, double math, double english):basename, age)this.chinese = chinese;this.math = math;this.english = english;public override doub

47、le Average()return (chinese + math + english) / 3;public classCollege : Studentprotected double required;protected double elective;public College(string name,int age, double required, double elective):basename, age)this.required = required;this.elective = elective;public override double Average。retu

48、rn (required + elective) / 2;Form窗體內(nèi)的代碼:using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespaceTest5_1public partial classForm1 : Form public Form1()InitializeComponent(); private void btnSmall_Click(

49、object sender, EventArgs e) Pupilp=newPupil (txtName.Text, Convert .ToInt32(txtAge.Text), Convert .ToDouble(txtChinese.Text), Convert.ToDouble(txtMath .Text);lblShow.Text +="總?cè)藬?shù):"+Convert.ToString( Student.number) + "," + "姓名:"+ p.Name + "," + "小學(xué)生"+

50、 "," + "平均成績(jī)?yōu)椋?quot;+ p.Average() +"n"private void btnMiddle_Click( object sender, EventArgs e) Middle m = new Middle (txtName.Text, Convert.ToInt32(txtAge.Text), Convert .ToDouble(txtChinese.Text), Convert.ToDouble(txtMath.Text), Convert .ToDouble(TxtEnglish.Text);lblShow.T

51、ext +="總?cè)藬?shù):"+ Convert.ToString(Student.number) + "," + "姓名:"+ m.Name + "," + "中學(xué)生"+ "," + "平均成績(jī)?yōu)椋?quot;+ m.Average() + "n"private void btnBig_Click( object sender, EventArgs e) College c = new College。xtName.Text, Convert.ToI

52、nt32(txtAge.Text), Convert .ToDouble(txtChinese.Text), Convert.ToDouble(txtMath.Text);lblShow.Text +="總?cè)藬?shù):"+ Convert.ToString(Student.number) + "," + "姓名:"+ c.Name + "," + "大學(xué)生"+ "," + "平均成績(jī)?yōu)椋?quot;+ c.Average() + "n" 2、設(shè)計(jì)一個(gè)

53、Windows應(yīng)用程序,在該程序中定義平面圖形抽象類和派生類圓,矩形和 三角形。Figure類代碼:using System;using System.Collections.Generic;using System.Text;namespace Test5_2 public abstract class Figure public abstract double Area(); public class Circle : Figure double radius; public Circle( double r) radius = r; public override double Area

54、() return radius * radius * 3.14; public class JUxing: Figure double chang; double kuan; public JUxing( double c, double k) this .chang = c;this .kuan = k; public override double Area() return chang * kuan; public class San: Figure double bian; double heigth; public San( double b, double h)this .bia

55、n = b;this .heigth = h; public override double Area() return bian * heigth / 2; Form窗體代碼:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace Test5_2 public partial class Forml : Form p

56、ublic Form1() InitializeComponent(); private void btnCircle_Click( object sender, EventArgs e) Circle c= new Circle (Convert .ToInt32(TxtChang.Text); lblShow.Text ="圓的面積為:"+ c.Area();private void btnJu_Click( object sender, EventArgs e) JUxing j = newJUxing ( Convert .ToInt32(TxtChang.Text), C

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(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)論