C#学生成绩管理系统Word下载.docx

上传人:b****5 文档编号:21469628 上传时间:2023-01-30 格式:DOCX 页数:16 大小:206.33KB
下载 相关 举报
C#学生成绩管理系统Word下载.docx_第1页
第1页 / 共16页
C#学生成绩管理系统Word下载.docx_第2页
第2页 / 共16页
C#学生成绩管理系统Word下载.docx_第3页
第3页 / 共16页
C#学生成绩管理系统Word下载.docx_第4页
第4页 / 共16页
C#学生成绩管理系统Word下载.docx_第5页
第5页 / 共16页
点击查看更多>>
下载资源
资源描述

C#学生成绩管理系统Word下载.docx

《C#学生成绩管理系统Word下载.docx》由会员分享,可在线阅读,更多相关《C#学生成绩管理系统Word下载.docx(16页珍藏版)》请在冰豆网上搜索。

C#学生成绩管理系统Word下载.docx

三、实验内容

设计一个Windows应用程序,在该程序中定义一个学生类和班级类,以处理每个学生的学号、姓名、语文、数学和英语3门课程的期末考试成绩

(1)能查询每个学生的总成绩;

(2)能显示全班前3名的名单;

(3)能显示单科成绩最高分和不及格的学生名单;

(4)能统计全班学生的平均成绩;

(5)能显示各科成绩在不同分数段的学生人数百分比。

四、设计思路 

(1)定义一个Student学生类,包含字段(学号、姓名、语文成绩、数学成绩、英语成绩)和属性(总成绩)等;

(2)定义一个StudentList班级类,包含一个Student类型的数组(用来保存全班学生的信息)以及若干个实现上述要求的方法等;

(3)设计用户操作界面,首先让用户能输入一个学生的信息,当单击“添加”按钮时把这些信息添加班级对象的学生数组中。

当单击“完成”按钮时调用班级类的方法来显示所要求统计的统计结果。

当用户在查询框中输入学生的名字,并单击“查询”按钮时显示该学生的总成绩。

五、实验步骤

1、添加必要控件:

6个able控件,5个textbox控件,6个button控件

2、对其属性进行修改如下表

控件类型

控件名称

属性

设置结果

From

From1

Text

期末考试成绩

TextBox

textBox1

Name

textBox2

textBox3

textBox4

Button

Button1

添加

add

Button2

查询

chaxun

Button3

前三名

third

Button4

最高成绩和挂科

Best

Button5

平均总成绩

pingjun

Button6

及格率

jige

Able

able1

姓名

Able2

学号

Able4

英语成绩

Able5

语文成绩

Able6

数学成绩

Able7

3.编写代码

namespaceWindowsApplication3

{

publicpartialclassForm1:

Form

{

studentlistss=newstudentlist();

publicForm1()

InitializeComponent();

}

privatevoidadd_Click_1(objectsender,EventArgse)//添加

StudentS=newStudent();

S.name=txtname.Text;

S.ID=txtID.Text;

S.math=Convert.ToInt32(txtmath.Text);

S.chinese=Convert.ToInt32(txtchinese.Text);

S.english=Convert.ToInt32(txtenglish.Text);

ss.addstu(S);

privatevoidchaxun_Click_1(objectsender,EventArgse)//查询

intpos=ss.searchstu(this.txtname.Text);

if(pos!

=-1)

txtID.Text=ss.students[pos].ID;

txtmath.Text

Convert.ToString(ss.students[pos].math);

txtchinese.TextConvert.ToString(ss.students[pos].chinese);

txtenglish.Text=Convert.ToString(ss.students[pos].english);

else{MessageBox.Show("

没有此人"

"

提示信息"

);

privatevoidthird_Click_1(objectsender,EventArgse)//前三名

label6.Text="

"

;

ss.sort();

for(inti=0;

i<

3;

i++)

{label6.Text+=ss.students[i].name+'

\n'

privatevoidbest_Click_1(objectsender,EventArgse)//最高成绩和挂科

label6.Text=ss.getMaxAndLoser();

privatevoidpingjun_Click_1(objectsender,EventArgse)//平均总成绩

label6.Text=Convert.ToString(ss.allavescore());

privatevoidjige_Click_1(objectsender,EventArgse)

label6.Text=ss.jigelv();

privatevoidForm1_Load(objectsender,EventArgse)

}

classStudent//学生类

publicstringname;

publicstringID;

publicintchinese;

publicintmath;

publicintenglish;

publicintTotalscore

get{returnchinese+math+english;

classstudentlist//学生表

publicStudent[]students=newStudent[10];

publicintsnums;

publicstudentlist()

{snums=0;

publicvoidaddstu(Students)

students[snums]=s;

snums++;

publicintsearchstu(stringname)

inti;

for(i=0;

snums;

{if(students[i].name==name)break;

if(i==snums)return-1;

elsereturni;

publicvoidsort()//查询

intk=i;

for(intj=i+1;

j<

j++)

if(students[j].Totalscore>

students[k].Totalscore)

k=j;

if(k!

=i)

Studenttemp;

temp=students[k];

students[k]=students[i];

students[i]=temp;

privateintgetMaxer(intk)

intp=0;

if(k==0)

for(inti=1;

if(students[i].math>

students[p].math)

p=i;

elseif(k==1)

if(students[i].chinese>

students[p].chinese)

else

returnp;

publicstringgetMaxAndLoser()

stringMaxer="

"

Loser="

Maxer+="

单科数学最高:

+students[getMaxer(0)].name+"

\n"

单科语文最高:

+students[getMaxer

(1)].name+"

单科英语最高:

+students[getMaxer

(2)].name+"

Loser+="

单科数学挂科名单:

+getLoser(0)+"

单科语文挂科名单:

+getLoser

(1)+"

单科英语挂科名单:

+getLoser

(2)+"

returnMaxer+"

+Loser;

privatestringgetLoser(intk)

stringresult="

if(students[i].math<

60)result+=students[i].name+"

if(students[i].chinese<

if(students[i].english<

returnresult;

publicstringallavescore()

intallave=0,allscore=0;

allscore=students[i].math+students[i].chinese+students[i].english;

allave=allave+allscore;

return"

平均成绩为:

+allave/snums;

publicdoublejige(intk)

doublew=0;

60)w=w+1.0;

if(students[i].english>

returnw/(double)snums;

publicstringjigelv()

stringpass="

pass+="

数学及格率为:

+jige(0)+"

语文及格率:

+jige

(1)+"

英语及格率:

+jige

(2)+"

returnpass;

4.实现运行

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > IT计算机 > 电脑基础知识

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1