1.����ѧ������ϵͳԴ��
2.学生信息管理系统源代码
����ѧ������ϵͳԴ��
//主类EnglishTest——
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class EnglishTest extends JFrame
{
TestArea testPanel=null;
Container con=null;
public EnglishTest()
{
super("模拟考试");
testPanel=new TestArea();
con=getContentPane();
con.add(testPanel,初中初中BorderLayout.CENTER);
addWindowListener(new WindowAdapter()
{ public void windowClosing(WindowEvent e)
{ System.exit(0);
}
});
setVisible(true);
setBounds(,,,);
con.validate();
validate();
}
public static void main(String args[])
{
new EnglishTest();
}
}
//读取试题 ReadTestquestion
import java.io.*;
import java.util.*;
public class ReadTestquestion
{ String filename="",
correctAnswer="",
testContent="" ,
selection="" ;
int score=0;
long time=0;
boolean 完成考试=false;
File f=null;
FileReader in=null;
BufferedReader 读取=null;
public void setFilename(String name)
{ filename=name;
score=0;
selection="";
try {
if(in!=null&&读取!=null)
{
in.close();
读取.close();
}
f=new File(filename);
in=new FileReader(f);
读取=new BufferedReader(in);
correctAnswer=(读取.readLine()).trim();
String temp=(读取.readLine()).trim() ;
StringTokenizer token=new StringTokenizer(temp,":");
int hour=Integer.parseInt(token.nextToken()) ;
int minute=Integer.parseInt(token.nextToken());
int second=Integer.parseInt(token.nextToken());
time=*(second+minute*+hour**);
}
catch(Exception e)
{
testContent="没有选择试题";
}
}
public String getFilename()
{
return filename;
}
public long getTime()
{
return time;
}
public void set完成考试(boolean b)
{
完成考试=b;
}
public boolean get完成考试()
{
return 完成考试;
}
public String getTestContent()
{ try {
String s=null;
StringBuffer temp=new StringBuffer();
if(读取!=null)
{
while((s=读取.readLine())!=null)
{
if(s.startsWith("**"))
break;
temp.append("\n"+s);
if(s.startsWith("endend"))
{
in.close();
读取.close();
完成考试=true;
}
}
testContent=new String(temp);
}
else
{
testContent=new String("没有选择试题");
}
}
catch(Exception e)
{
testContent="试题内容为空,考试结束!!学生系统绝地选股源码";
}
return testContent;
}
public void setSelection(String s)
{
selection=selection+s;
}
public int getScore()
{ score=0;
int length1=selection.length();
int length2=correctAnswer.length();
int min=Math.min(length1,管理量能买入指标源码length2);
for(int i=0;i<min;i++)
{ try{
if(selection.charAt(i)==correctAnswer.charAt(i))
score++;
}
catch(StringIndexOutOfBoundsException e)
{
i=0;
}
}
return score;
}: -8-
public String getMessages()
{
int length1=selection.length();
int length2=correctAnswer.length();
int length=Math.min(length1,length2);
String message="正确答案:"+correctAnswer.substring(0,length)+"\n"+
"你的回答:"+selection+"\n";
return message;
}
}
//考试区域TestArea
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.io.*;
class FileName implements FilenameFilter
{
String str=null;
FileName (String s)
{
str="."+s;
}
public boolean accept(File dir,String name)
{
return name.endsWith(str);
}
}
public class TestArea extends JPanel implements ActionListener,ItemListener,Runnable
{
Choice list=null;
JTextArea 试题显示区=null,消息区=null;
JCheckBox box[];
JButton 提交该题答案,读取下一题,查看分数;
ReadTestquestion 读取试题=null;
JLabel welcomeLabel=null;
Thread countTime=null;
long time=0;
JTextField timeShow=null;
boolean 是否关闭计时器=false,
是否暂停计时=false;
JButton 暂停或继续计时=null;
public TestArea()
{
list= new Choice();
String 当前目录=System.getProperty("user.dir");
File dir=new File(当前目录);
FileName fileTxt=new FileName("txt");
String fileName[]=dir.list(fileTxt);
for(int i=0;i<fileName.length;i++)
{
list.add(fileName[i]);
}
试题显示区=new JTextArea(,);
试题显示区.setLineWrap(true);
试题显示区.setWrapStyleWord(true);
试题显示区.setFont(new Font("TimesRoman",Font.PLAIN,));
试题显示区.setForeground(Color.blue);
消息区=new JTextArea(8,8);
消息区.setForeground(Color.blue);
消息区.setLineWrap(true);
消息区.setWrapStyleWord(true);
countTime=new Thread(this);
String s[]={ "A","B","C","D"};
box=new JCheckBox[4];
for(int i=0;i<4;i++)
{
box[i]=new JCheckBox(s[i]);
}
暂停或继续计时=new JButton("暂停计时");
暂停或继续计时.addActionListener(this);
提交该题答案=new JButton("提交该题答案");
读取下一题=new JButton("读取第一题");
读取下一题.setForeground(Color.blue);
提交该题答案.setForeground(Color.blue);
查看分数=new JButton("查看分数");
查看分数.setForeground(Color.blue);
提交该题答案.setEnabled(false);
提交该题答案.addActionListener(this);
读取下一题.addActionListener(this);
查看分数.addActionListener(this);
list.addItemListener(this);
读取试题=new ReadTestquestion();
JPanel pAddbox=new JPanel();
for(int i=0;i<4;i++)
{
pAddbox.add(box[i]);
}
Box boxH1=Box.createVerticalBox(),
boxH2=Box.createVerticalBox(),
baseBox=Box.createHorizontalBox();
boxH1.add(new JLabel("选择试题文件"));
boxH1.add(list);
boxH1.add(new JScrollPane(消息区));
boxH1.add(查看分数);
timeShow=new JTextField();
timeShow.setHorizontalAlignment(SwingConstants.RIGHT);
timeShow.setEditable(false);
JPanel p1=new JPanel();
p1.add(new JLabel("剩余时间:"));
p1.add(timeShow);
p1.add(暂停或继续计时);
boxH1.add(p1);
boxH2.add(new JLabel("试题内容:"));
boxH2.add(new JScrollPane(试题显示区));
JPanel p2=new JPanel();
p2.add(pAddbox);
p2.add(提交该题答案);
p2.add(读取下一题);
boxH2.add(p2);
baseBox.add(boxH1);
baseBox.add(boxH2);
setLayout(new BorderLayout());
add(baseBox,BorderLayout.CENTER);
welcomeLabel=new JLabel("欢迎考试,提高英语水平",JLabel.CENTER);
welcomeLabel.setFont(new Font("隶书",Font.PLAIN,));
welcomeLabel.setForeground(Color.blue);
add(welcomeLabel,BorderLayout.NORTH);
}
public void itemStateChanged(ItemEvent e)
{
timeShow.setText(null);
是否关闭计时器=false;
是否暂停计时=false;
暂停或继续计时.setText("暂停计时");
String name=(String)list.getSelectedItem();
读取试题.setFilename(name);
读取试题.set完成考试(false);
time=读取试题.getTime();
if(countTime.isAlive())
{
是否关闭计时器=true;
countTime.interrupt();
}
countTime=new Thread(this);
消息区.setText(null);
试题显示区.setText(null);
读取下一题.setText("读取第一题");
提交该题答案.setEnabled(false);
读取下一题.setEnabled(true);
welcomeLabel.setText("欢迎考试,你选择的试题:"+读取试题.getFilename());
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==读取下一题)
{
读取下一题.setText("读取下一题");
提交该题答案.setEnabled(true);
String contentTest=读取试题.getTestContent();
试题显示区.setText(contentTest);
消息区.setText(null);
读取下一题.setEnabled(false);
try {
countTime.start();
}
catch(Exception event)
{
}
}
if(e.getSource()==提交该题答案)
{
读取下一题.setEnabled(true);
提交该题答案.setEnabled(false);
String answer="?";
for(int i=0;i<4;i++)
{
if(box[i].isSelected())
{
answer=box[i].getText();
box[i].setSelected(false);
break;
}
}
读取试题.setSelection(answer);
}
if(e.getSource()==查看分数)
{
int score=读取试题.getScore();
String messages=读取试题.getMessages();
消息区.setText("分数:"+score+"\n"+messages);
}
if(e.getSource()==暂停或继续计时)
{
if(是否暂停计时==false)
{
暂停或继续计时.setText("继续计时");
是否暂停计时=true;
}
else if(是否暂停计时==true)
{
暂停或继续计时.setText("暂停计时");
是否暂停计时=false;
countTime.interrupt();
}
}
}
public synchronized void run()
{
while(true)
{
if(time<=0)
{
是否关闭计时器=true;
countTime.interrupt();
提交该题答案.setEnabled(false);
读取下一题.setEnabled(false);
timeShow.setText("用时尽,考试结束");
}
else if(读取试题.get完成考试())
{
是否关闭计时器=true;
timeShow.setText("考试效果:分数*剩余时间(秒)="+1.0*读取试题.getScore()*(time/));
countTime.interrupt();
提交该题答案.setEnabled(false);
读取下一题.setEnabled(false);
}
else if(time>=1)
{
time=time-;
long leftTime=time/;
long leftHour=leftTime/;
long leftMinute=(leftTime-leftHour*)/;
long leftSecond=leftTime%;
timeShow.setText(""+leftHour+"小时"+leftMinute+"分"+leftSecond+"秒");
}
try
{
Thread.sleep();
}
catch(InterruptedException ee)
{
if(是否关闭计时器==true)
return ;
}
while(是否暂停计时==true)
{
try
{
wait();
}
catch(InterruptedException ee)
{
if(是否暂停计时==false)
{
notifyAll();
}
}
}
}
}
}
学生信息管理系统源代码
void Sort(student *&head, char type,char maxOrMin)
{
/*参数说明:
type=='1' 按 语文 排列
type=='2' 按 数学 排列
type=='3' 按 英语 排列
type=='4' 按 总分 排列
type=='5' 按 平均分 排列
type=='6' 按 座号 排列
*/
student *pHead,*pH;
pHead=pH=head;
int len=GetLength(head);
float *array=new float[len];
int i;
int x=0;
float num=0;
while(head)
{
Count(head);
if(type=='1')
{
num=head->chinaNum;
}
else if(type=='2')
{
num=head->mathNum;
}
else if(type=='3')
{
num=head->englishNum;
}
else if(type=='4')
{
num=head->result;
}
else if(type=='5')
{
num=head->average;
}
else if(type=='6')
{
num=head->num;
}
array[x]=num;
x++;
head=head->next;
}
head=pHead;
if(maxOrMin=='1')
{
for( i=1; i<len; i++)
{
for(int j=0; j<len-i; j++)
{
if(array[j]<array[j+1])
{
float num;
num=array[j];
array[j]=array[j+1];
array[j+1]=num;
}
}
}
}
else
{
for( i=1; i<len; i++)
{
for(int j=0; j<len-i; j++)
{
if(array[j]>array[j+1])
{
float num;
num=array[j];
array[j]=array[j+1];
array[j+1]=num;
}
}
}
}
int pos=1;
for(i=0; i<len; i++)
{
head=pHead;
while(head)
{
if(type=='1')
{
num=head->chinaNum;
}
else if(type=='2')
{
num=head->mathNum;
}
else if(type=='3')
{
num=head->englishNum;
}
else if(type=='4')
{
num=int(head->result);
}
else if(type=='5')
{
num=int(head->average);
}
else if(type=='6')
{
num=int(head->num);
}
int n=0;
if(int(array[i])==int(num))
{
if(int(array[i])!=int(array[i+1]))
{
if(n==0)
{
n=pos;
}
head->pos=pos;
pos++;
}
else
{
head->pos=n;
}
}
head=head->next;
}
}
head=pH;
delete []array;
}
void Count(student *&head)
{
head->result=head->chinaNum+head->englishNum+head->mathNum;
head->average=head->result/3;
}
void DeleteAll(student* &head)
{
student *cp,*np;
cp=head;
while(cp)
{
np=cp->next;
delete cp;
cp=np;
}
head=NULL;
}
void ChaXun(string str,student *head)
{
Sort(head,'4','1');
cout<<"欢迎使用查询功能"<<endl<<endl;
cout<<"请输入你要按什么查询 1->一般查询 2->查找最多 3->查找最少"<<endl;
string s;
cin>>s;
while(s[0]!='1'&&s[0]!='2'&&s[0]!='3')
{
cout<<"你输入错误,请重新输入."<<endl;
cin>>s;
}
if(s[0]=='1')
{
cout<<"按什么查询?"<<endl;
cout<<"1->姓名 2->座号 3->语文成绩 4->数学成绩 "
<<"5->英语成绩 6->总分 7->平均分 8->排名"<<endl;
cin>>str;
while(str[0]!='1' && str[0]!='2' &&
str[0]!='3' && str[0]!='4' &&
str[0]!='5' && str[0]!='6' &&
str[0]!='7' && str[0]!='8' )
{
cout<<"你输入错误,请重新输入."<<endl;
cin>>str;
}
char findStr[];
cout<<"请输入要查找的关键字或关键数:"<<endl;
cin>>findStr;
switch(str[0])
{
case '1':
Find(head,findStr,'1');
break;
case '2':
Find(head,findStr,'2');
break;
case '3':
Find(head,findStr,'3');
break;
case '4':
Find(head,findStr,'4');
break;
case '5':
Find(head,findStr,'5');
break;
case '6':
Find(head,findStr,'6');
break;
case '7':
Find(head,findStr,'7');
break;
case '8':
Find(head,findStr,'8');
break;
}
}
else if(s[0]=='2')
{
cout<<"请输入要按什么查询?"<<endl;
cout<<"1->语文成绩 2->数学成绩 "
<<"3->英语成绩 4->总分 5->平均分 6->排名"<<endl;
string s;
cin>>s;
switch(s[0])
{
case '1':
FindMaxOrMin(head,'1','1');
break;
case '2':
FindMaxOrMin(head,'2','1');
break;
case '3':
FindMaxOrMin(head,'3','1');
break;
case '6':
FindMaxOrMin(head,'6','1');
break;
case '5':
FindMaxOrMin(head,'5','1');
break;
default:
FindMaxOrMin(head,'4','1');
break;
}
}
else if(s[0]=='3')
{
cout<<"请输入要按什么查询?"<<endl;
cout<<"1->语文成绩 2->数学成绩 "
<<"3->英语成绩 4->总分 5->平均分 6->排名"<<endl;
string s;
cin>>s;
switch(s[0])
{
case '1':
FindMaxOrMin(head,'1','2');
break;
case '2':
FindMaxOrMin(head,'2','2');
break;
case '3':
FindMaxOrMin(head,'3','2');
break;
case '6':
FindMaxOrMin(head,'6','2');
break;
case '5':
FindMaxOrMin(head,'5','2');
break;
default:
FindMaxOrMin(head,'4','2');
break;
}
}
}
void ZengJia(string str, student* &head)
{
student *pNew=new student;
cout<<"欢迎使用增加功能"<<endl<<endl;
cout<<"请输入新学生的名字 :"<<endl;
cin>>pNew->name;
cout<<"请输入新学生的座号 :"<<endl;
cin>>pNew->num;
cout<<"请输入他的语文分数 :"<<endl;
cin>>pNew->chinaNum;
cout<<"请输入他的数学分数"<<endl;
cin>>pNew->mathNum;
cout<<"请输入他的英语分数"<<endl;
cin>>pNew->englishNum;
cout<<"插入记录的 (1->最前面 2->最后面)"<<endl;
cin>>str;
while(str[0]!='1' && str[0]!='2')
{
cout<<"你输入错误,请重新输入."<<endl;
cout<<"插入记录的 (1->最前面 2->最后面)"<<endl;
cin>>str;
}
if(str[0]=='1')
{
InsertFront(head,pNew);
}
else if(str[0]=='2')
{
InsertRear(head,pNew);
}
cout<<"新学生增加成功."<<endl;
}
void ShanChu(string str, student *&head)
{
char delStr[];
cout<<"欢迎使用删除功能"<<endl<<endl;
cout<<"1->查询删除 2->全部删除"<<endl;
cin>>str;
while(str[0]!='1' && str[0]!='2')
{
cout<<"输入错误,请重新输入."<<endl;
cin>>str;
}
if(str[0]=='1')
{
cout<<"请输入要删除的关键字"<<endl;
cin>>delStr;
cout<<"1->删除第一条找到的记录 2->删除所有找到的记录"<<endl;
cin>>str;
while(str[0]!='1'&&str[0]!='2')
{
cout<<"你输入错误,请重新输入."<<endl;
cin>>str;
}
cout<<"你真的要删除吗? 1->删除 2->取消"<<endl;
string s;
cin>>s;
if(str[0]=='1')
{
if(str[0]=='1')
{
Delete(head,delStr,1);
}
else
{
Delete(head,delStr,2);
}
}
else
{
cout<<"你已经取消删除了."<<endl;
}
}
else
{
cout<<"你真的要删除全部数据吗?这样会使你的数据全部丢失哦."<<endl;
cout<<"1->全部删除 2->取消删除"<<endl;
cin>>str;
if(str[0]=='1')
{
DeleteAll(head);
}
else
{
cout<<"你已经取消删除了."<<endl;
}
}
}
void PaiMing(string str, student* head)
{
string s;
cout<<"欢迎使用排名功能"<<endl<<endl;
cout<<"排名选择: 1->升序 2->降序"<<endl;
cin>>s;
cout<<"请输入要按什么排名?"<<endl;
cout<<"1->语文成绩 2->数学成绩 3->英语成绩 "
<<"4->总分 5->平均分 6->座号"<<endl;
cin>>str;
while(str[0]!='1' && str[0]!='2' &&
str[0]!='3' && str[0]!='4' &&
str[0]!='5' && str[0]!='6' )
{
cout<<"你输入错误,请重新输入."<<endl;
cin>>str;
}
cout<<"姓名:"<<setw(8)<<"座号:"<<setw()
<<"语文分数:"<<setw() <<"数学分数:"
<<setw()<<"英语分数:"<<setw(8)<<"总分数:"
<<setw(8)<<"平均分:"<<setw(6)<<"名次:"<<endl<<endl;
if(s[0]=='2')
{
switch(str[0])
{
case '1':
Sort(head,'1','1');
break;
case '2':
Sort(head,'2','1');
break;
case '3':
Sort(head,'3','1');
break;
case '4':
Sort(head,'4','1');
break;
case '5':
Sort(head,'5','1');
break;
case '6':
Sort(head,'6','1');
break;
}
}
else
{
switch(str[0])
{
case '1':
Sort(head,'1','2');
break;
case '2':
Sort(head,'2','2');
break;
case '3':
Sort(head,'3','2');
break;
case '4':
Sort(head,'4','2');
break;
case '5':
Sort(head,'5','2');
break;
case '6':
Sort(head,'6','2');
break;
}
}
ShowList(head);
return ;
}
void XianShi(string str, student *head)
{
Sort(head,'4','1');
string s;
cout<<"欢迎使用显示功能"<<endl;
cout<<"1->显示全部记录 2->显示记录数目"<<endl;
cin>>s;
if(s[0]=='2')
{
cout<<"记录的数目是:"<<GetLength(head)<<endl;
}
else
{
ShowList(head);
}
}
void XuiGai(string str, student *&head)
{
string s;
student *std;
cout<<"欢迎使用修改功能"<<endl;
cout<<"请输入你要按什么查询"<<endl;
cout<<"1->姓名 2->座号 3->语文成绩 4->数学成绩 "
<<"5->英语成绩 "<<endl;
cin>>str;
while(str[0]!='1' && str[0]!='2' &&
str[0]!='3' && str[0]!='4' &&
str[0]!='5' )
{
cout<<"你输入错误,请重新输入."<<endl;
cin>>str;
}
char findStr[];
cout<<"请输入要查找的关键字或关键数:"<<endl;
cin>>findStr;
switch(str[0])
{
case '1':
std=Find(head,findStr,'1');
Reword(std);
break;
case '2':
std=Find(head,findStr,'2');
Reword(std);
break;
case '3':
std=Find(head,findStr,'3');
Reword(std);
break;
case '4':
std=Find(head,findStr,'4');
Reword(std);
break;
case '5':
std=Find(head,findStr,'5');
Reword(std);
break;
}
Write(head);
if(std!=NULL)
{
cout<<"修改成功."<<endl;
}
}
int Run()
{
bool isLoad=false;
student* head=NULL;
student *pNew=new student;
head=Read();
SetTitle(false);
if(head!=NULL)
{ Sort(head,'5','1');
Count(head);
}
string str;
SetTitle(false);
cout<<" 欢迎使用学生管理系统 "<<endl<<endl;
cout<<" 1->用户登陆 2->退出程序 "<<endl;
cin>>str;
if(str[0]=='2')
{
AboutMe();
return 0;
}
else
{
isLoad=Enter('1');
system("cls");
if(isLoad==true)
{
SetTitle(true);
cout<<" 恭喜,您输入的密码正确.可以对本系统的进行任何操作."<<endl;
}
else
{
cout<<" Sorry,您输入的密码错误.你不能修改本系统的任何内容."<<endl;
}
}
begin:
cout<<endl<<endl;
cout<<" 欢迎使用学生管理系统 "<<endl<<endl;
cout<<" 1->增加功能 2-查询功能"<<endl;
cout<<" 3->删除功能 4-排名功能"<<endl;
cout<<" 5->显示功能 6-修改功能"<<endl;
cout<<" 7->用户设置 8-退出程序"<<endl;
cout<<"请输入您的选择: "<<endl;
cin>>str;
while(str[0]!='8')
{
if(isLoad==true && head!=NULL)
{
cout<<endl<<endl;
if(str[0]=='1')
{
ZengJia(str, head);
Sort(head,'4','1');
Write(head);
}
else if(str[0]=='2')
{
ChaXun(str,head);
}
else if(str[0]=='3')
{
ShanChu(str,head);
Sort(head,'4','1');
Write(head);
}
else if(str[0]=='4')
{
PaiMing(str,head);
}
else if(str[0]=='5')
{
XianShi(str,head);
}
else if(str[0]=='6')
{
XuiGai(str,head);
Write(head);
}
else if(str[0]=='7')
{
cout<<"欢迎使用用户修改功能"<<endl;
isLoad=Enter('2');
}
else if(str[0]=='8')
{
AboutMe();
return 0;
}
else
{
cout<<"你输入错误,请重新输入."<<endl;
goto begin;
}
}
else if(isLoad==false && head!=NULL)
{
if(str[0]=='2')
{
ChaXun(str,head);
}
else if(str[0]=='4')
{
PaiMing(str,head);
}
else if(str[0]=='5')
{
XianShi(str,head);
}
else
{
cout<<"你不是管理员,不能进行此项功能."<<endl;
cout<<"你只能进行 查询功能 显示功能 排名功能"<<endl;
}
}
else if( head==NULL && isLoad==true)
{
cout<<"系统检查到你没有任何记录,不能进行任何操作,只能增加记录."<<endl;
ZengJia(str, head);
Write(head);
head=Read();
}
else if( head==NULL && isLoad==false)
{
cout<<"因为你没有登陆,系统又检查到你没有任何记录,你不能进行任何操作."<<endl;
}
cout<<endl<<endl;
cout<<"按任何键继续进行操作."<<endl;
getchar();
getchar();
system("cls");
goto begin;
}
AboutMe();
return 0;
}
void SetTitle(bool isLoad)
{
HWND hwnd=GetForegroundWindow();
if(isLoad==false)
{
SetWindowText(hwnd," 学生管理系统(没有登陆)");
}
else
{
SetWindowText(hwnd," 学生管理系统(已经登陆)");
}
system("color a");
}
void AboutMe()
{
char*pStr= " ┃ \n"
" ┃ \n"
" ┏━━━━┻━━━━┓ \n"
" ┃ 关于作者 ┃ \n"
" ┏━━━━┻━━━━━━━━━┻━━━━┓\n"
" ┃ ┃\n"
" ┃ Aauthor:
2024-11-29 21:48160人浏览
2024-11-29 21:162124人浏览
2024-11-29 20:31618人浏览
2024-11-29 19:592983人浏览
2024-11-29 19:441723人浏览
2024-11-29 19:411431人浏览
1.喵喵爱钓鱼红包版如何2.欢乐钓鱼大师红包能提现吗3.老人如何识别高科技诈骗4.钓鱼红包是什麼意思喵喵爱钓鱼红包版如何 下载地址:/azyx/yzxx/zuozuoaidiaoyuv.html