代码如下:
for(i=0i<66i++)

printf("*")
printf("n")
printf("1.Input recordn")
printf("2.Caculate totel and average score of every coursen")
printf("3.Caculate totel and average score of every studentn")
printf("4.Sort in descending order by total score of every studentn")
printf("5.Sort in ascending order by total score of every studentn")
printf("6.Sort in ascending order by numbern")
printf("7.Sort in ascending order by namen")
printf("8.Search by numbern")
printf("9.Search by namen")
printf("10.Statistic analysis for every coursen")
printf("11.List recordn")
printf("12.Write to a filen")
printf("13.Read from a filen")
printf("0.Exitn")
for(i=0i<66i++)
printf("*")
printf("n")
printf("Please enter your choice:")
printf("n")
输入函数:
void Readscore (STU stu[],int n,int m) //1.输入数据
{
int i,j
for(i=0i<ni++)
{
printf("Input student's ID ,name and score")
scanf("%ld",&stu[i].studentID)
scanf("%s",stu[i].studentName)
for(j=0j<mj++)
scanf("%d",&stu[i].score[j])
}
}
数据处理函数:
void Tota (STU stu[],int n,int m) //2.计算每门课程的总分和平均分
{
int i,j,sum[M]
double ave[M]
for(j=0j<mj++)
{
sum[j]=0
for(i=0i<ni++)
{
sum[j]=sum[j]+stu[i].score[j]
}
ave[j]=(double)sum[j]/n
}
for(i=0i<mi++)
printf("Project %d 总分=%d,课程的平均分=%fn",i+1,sum[i],ave[i])
}
void Datasort_1 (STU stu[],int n,int m) //3.计算每个学生的总分和平均分
{
int i,j,sum[N]
double ave[N]
for(i=0i<ni++)
{
sum[i]=0
for(j=0j<mj++)
{
sum[i]=sum[i]+stu[i].score[j]
}
ave[i]=(double)sum[i]/m
}
for(i=0i<ni++)
printf("ID:%10ld,Name: %s Allscore=%d,The ave=%fn",stu[i].studentID,stu[i].studentName,sum[i],ave[i])
}
排序函数:
void Datasort_2 (STU stu[],int n,int m) //4.按每个学生的总分由高到低排出名次表
{
int i,j,k,h,sum[N]
STU t
for(i=0i<ni++)
{
sum[i]=0
for(j=0j<mj++)
{
sum[i]=sum[i]+stu[i].score[j]
}
}
for(i=0i<ni++)
{
k=i
for(j=i+1j<nj++)
{
if (sum[j]>sum[k])
k=j
}
if(i!=k)
{
t=stu[i],h=sum[i]
stu[i]=stu[k],sum[i]=sum[k]
stu[k]=t,sum[k]=h
}
}
for(i=0i<ni++)
printf("ID:%10ld,Name:%s,Score:%dn",stu[i].studentID,stu[i].studentName,sum[i])
}
void Datasort_3 (STU stu[],int n,int m) //5.按每个学生的总分由低到高排出名次表
{
int i,j,k,h,sum[N]
STU t
for(i=0i<ni++)
{
sum[i]=0
for(j=0j<mj++)
{
sum[i]=sum[i]+stu[i].score[j]
}
}
for(i=0i<ni++)
{
k=i
for(j=i+1j<nj++)
{
if (sum[j]<sum[k])
k=j
}
if(i!=k)
{
t=stu[i],h=sum[i]
stu[i]=stu[k],sum[i]=sum[k]
stu[k]=t,sum[k]=h
}
}
for(i=0i<ni++)
printf("ID:%10ld,Name:%s,score:%dn",stu[i].studentID,stu[i].studentName,sum[i])
}
void Datasort_4 (STU stu[],int n,int m) //6.按学号由小到大排出名次表
{
int i,j,k
STU t
for(i=0i<ni++)
{
k=i
for(j=i+1j<nj++)
{
if (stu[j].studentID<stu[k].studentID)
k=j
}
if(i!=k)
t=stu[k],stu[k]=stu[i],stu[i]=t
}
for(i=0i<ni++)
{
printf("ID:%10ld,Name:%sn",stu[i].studentID,stu[i].studentName)
for(j=0j<mj++)
printf("Project %d Score:%dn",j+1,stu[i].score[j])
}
}
数据分析函数:
void Statistis (STU stu[],int n,int m) //10.
{
int i,j,count_1,count_2,count_3,count_4,count_5
for(j=0j<mj++)
{
count_1=0,count_2=0,count_3=0,count_4=0,count_5=0
for(i=0i<ni++)
{
if(stu[i].score[j]>=90)
count_1++
else if(stu[i].score[j]>=80)
count_2++
else if(stu[i].score[j]>=70)
count_3++
else if(stu[i].score[j]>=60)
count_4++
else
count_5++
}
printf("project %dn",j+1)
printf("优秀:%dt优秀率:%f%n",count_1,(float)count_1/n)
printf("良好:%dt良好率:%f%n",count_2,(float)count_2/n)
printf("中等:%dt中等率:%fn",count_3,(float)count_3/n)
printf("及格:%dt及格率:%fn",count_4,(float)count_4/n)
printf("不及格:%dt不及格率:%fn",count_5,(float)count_5/n)
}
}
数据界面打印函数:
void List (STU stu[],int n,int m) //11.
{
int i,j,sum[N]
double ave[N]
for(i=0i<ni++)
{
sum[i]=0
for(j=0j<mj++)
{
sum[i]=sum[i]+stu[i].score[j]
}
ave[i]=(double)sum[i]/m
}
for(i=0i<ni++)
{
printf("ID:%10ld,Name:%sn",stu[i].studentID,stu[i].studentName)
for(j=0j<mj++)
{
printf("Score %d :%dn",j+1,stu[i].score[j])
}
printf("Allscore=%dn平均分%fn",sum[i],ave[i])
}
}
文件处理函数:
void WritetoFile(STU stu[],int n,int m) //将每个学生的记录信息写入文件
{
Tota(stu,n,m)
Datasort_2 (stu,n,m)
FILE *fp
if((fp=fopen("student.txt","w"))==NULL)
{
printf("Failure to open student.txt!n")
exit(0)
}
fwrite(stu,sizeof(STU),n,fp)
fclose(fp)
}
int ReadfromFile(STU stu[],int n,int m)//从文件中读出每个学生的记录信息并显示
{
FILE *fp
int i
if((fp=fopen("student.txt","r"))==NULL)
{
printf("Failure to open student.txt!n")
exit(0)
}
for(i=0!feof(fp)i++)
{
fread(&stu[i],sizeof(STU),1,fp)
}
fclose(fp)
printf("Total student is %d.n",i-1)
n=i-1
List(stu,n,m) //输出从文件中读出的信息到屏幕上
return i-1
}
我使用几系统都B/S结构每登录都需要输入用户名密码觉非麻烦考虑其同事需求妨写自登录程序吧前考虑使用单点登录几经尝试放弃
我习惯使用Java本能始寻找Java解决Google输入Java自登录、Java网页模拟登录、Java Post 登录结倒少内容差我尝试终究没达我预期目标我都知道些代码应该jsp页面执行c/s结构程序执行些代码确实管用
我先析代码
String surl = ""
URL url = new URL(surl)
URLConnection conn = url.openConnection()
conn.setDoOutput(true)
OutputStreamWriter out=new OutputStreamWriter(conn.getOutputStream())
String str = "username=yourname&password=123456"
out.write(str)
out.flush()
out.close()
C/S结构且参数确程序能够功登录oa系统要看结通面代码系统服务器返结System.out.println()
String sling = ""
String scontent = ""
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream(),"UTF-8"))
while ((sling = in.readLine()) != null)
scontent += in + "rn"
System.out.println(scontent)
C/S结构控制台输返值返内容看程序已经功登录要网址浏览器打重新登录问题没根本解决恶意注册应该达目
看C/S结构容易实现网页程序自登录除非C/S程序内嵌浏览器直接浏览器自访问系统应该没别主要问题于我没办共享Session
便于共享Session我能浏览器实现网页自登录通面代码jsp页面测试达预期目标
网页自登录希望程序自填充用户名密码Post式提交给登录页面Form所指向action页面或我系统登录页面源代码保存网页usernamepassword文本框设置默认值通网页登录系统测试发现行接能已经想解决
我通url.openConnection()建立连接返scontent打印接着打印代码:
out.println("rn")
原理简单通login.jsp登录页面全部源代码写前页面使用javascript脚本用户名密码值填充提交表单终于实现自登录目标现我通特殊网址例自访问oa
能注意参数url值经加密内容用户名密码加效期即效期内链接才效才实现自登录
以下方法实现了用户界面登陆
import java.awt.*
import java.awt.event.*
public class DengLuJieMian extends frame implements ActionListener
{
Label username=new Label("用户名:")//使用文本创建一个用户名标签
TextField t1=new TextField()//创建一个文本框对象
Label password=new Label("密码:")//创建一个密码标签
TextField t2=new TextField()
Button b1=new Button("登陆")//创建登陆按钮
Button b2=new Button("取消")//创建取消按钮
public DengLuJieMian()
{
this.setTitle("学生信息管理系统")//设置窗口标题
this.setLayout(null)//设置窗口布局管理器
username.setBounds(50,40,60,20)//设置姓名标签的初始位置
this.add(username)// 将姓名标签组件添加到容器
t1.setBounds(120,40,80,20)// 设置文本框的初始位置
this.add(t1)// 将文本框组件添加到容器
password.setBounds(50,100,60,20)//密码标签的初始位置
this.add(password)//将密码标签组件添加到容器
t2.setBounds(120,100,80,20)//设置密码标签的初始位置
this.add(t2)//将密码标签组件添加到容器
b1.setBounds(50,150,60,20)//设置登陆按钮的初始位置
this.add(b1)//将登陆按钮组件添加到容器
b2.setBounds(120,150,60,20)//设置取消按钮的初始位置
this.add(b2)// 将取消按钮组件添加到容器
b1.addActionListener(this)//给登陆按钮添加监听器
b2.addActionListener(this)// 给取消按钮添加监听器
this.setVisible(true)//设置窗口的可见性
this.setSize(300,200)//设置窗口的大小
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0)
}
})//通过内部类重写关闭窗体的方法
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b1)//处理登陆事件
{
String name=t1.getText()
String pass=t2.getText()
if(name!=null&&pass.equals("000123"))//判断语句
{
new StudentJieMian()
}
}
}
public static void main(String args[])//主函数
{
new DengLuJieMian()
}
}
以下方法实现了学生界面设计
import java.awt.*
import java.awt.event.*
class StudentJieMian extends frame implements ActionListener
{
MenuBar m=new MenuBar()//创建菜单栏
Menu m1=new Menu("信息")//创建菜单“信息”
MenuItem m11=new MenuItem("插入")//创建“插入”的菜单项
MenuItem m12=new MenuItem("查询")
Menu m2=new Menu("成绩")//创建菜单“成绩”
MenuItem m21=new MenuItem("查询")
public StudentJieMian()
{
this.setTitle("学生界面")//设置窗口标题
this.setLayout(new CardLayout())//设置窗口布局管理器
this.setMenuBar(m)//将菜单栏组件添加到容器
m.add(m1)//将信息菜单放入菜单栏
m.add(m2)
m1.add(m11)//将“插入”菜单项添加到“信息”菜单
m1.add(m12)//将“查询”菜单项添加到“信息”菜单
m2.add(m21)//将“查询”菜单项添加到“成绩”菜单
m11.addActionListener(this)//给“插入”菜单项添加监听器
m12.addActionListener(this)//给“查询”菜单项添加监听器
m21.addActionListener(this)//给“查询”菜单项添加监听器
this.setVisible(true)//设置窗口的可见性
this.setSize(300,200)//设置窗口的大小
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0)//关闭窗口
}
})
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==m11) //处理“添加信息”事件
{
new AddStudent()
}
if(e.getSource()==m12) //处理“查询信息”事件
{
new SelectStudent()
}
if(e.getSource()==m21) //处理“查询成绩”事件
{
new ChengJiStudent()
}
}
public static void main(String args[])
{new StudentJieMian() //创建一个对象 }
import java.awt.BorderLayout
import java.awt.CardLayout
import java.awt.Container
import java.awt.Font
import java.awt.event.ActionEvent
import java.awt.event.ActionListener
import javax.swing.Icon
import javax.swing.ImageIcon
import javax.swing.JButton
import javax.swing.Jframe
import javax.swing.JLabel
import javax.swing.JMenu
import javax.swing.JMenuBar
import javax.swing.JMenuItem
import javax.swing.JPanel
import javax.swing.JToolBar
import javax.swing.SwingConstants
public class Mainframe extends Jframe implements ActionListener{
InsertPanel ip = null
SelectPanel sp = null
JPanel pframe
JButton jb1,jb2,jb3
JMenuItem jm11,jm21,jm22,jm23,jm31,jm32,jm41,jm42
CardLayout clayout
public Mainframe(String s){
super(s)
JMenuBar mb = new JMenuBar()
this.setJMenuBar(mb)
JMenu m1 = new JMenu("系统")
JMenu m2 = new JMenu("基本信息")
JMenu m3 = new JMenu("成绩")
JMenu m4 = new JMenu("奖惩")
mb.add(m1)
mb.add(m2)
mb.add(m3)
mb.add(m4)
jm11 = new JMenuItem("退出系统")
jm21 = new JMenuItem("输入")
jm22 = new JMenuItem("查询")
jm23 = new JMenuItem("更改")
jm31 = new JMenuItem("输入成绩")
jm32 = new JMenuItem("查询成绩")
jm41 = new JMenuItem("奖励")
jm42 = new JMenuItem("处分")
m1.add(jm11)
m2.add(jm21)
m2.add(jm22)
m2.add(jm23)
m3.add(jm31)
m3.add(jm32)
m4.add(jm41)
m4.add(jm42)
Icon i1 = new ImageIcon()
Icon i2 = new ImageIcon()
Icon i3 = new ImageIcon()
jb1 = new JButton(i1)
jb1.setToolTipText("输入")
jb2 = new JButton(i2)
jb2.setToolTipText("查询")
jb3 = new JButton(i3)
jb3.setToolTipText("退出")
JToolBar tb = new JToolBar("系统工具")
tb.add(jb1)
tb.add(jb2)
tb.add(jb3)
add(tb,BorderLayout.NORTH)
jm11.addActionListener(this)
jm21.addActionListener(this)
jm22.addActionListener(this)
jb1.addActionListener(this)
jb2.addActionListener(this)
jb3.addActionListener(this)
clayout = new CardLayout()
pframe = new JPanel(clayout)
add(pframe)
JPanel mainp = new JPanel(new BorderLayout())
JLabel mainl = new JLabel("学生信息管理平台",SwingConstants.CENTER)
mainl.setFont(new Font("serif",Font.BOLD,30))
mainp.add(mainl)
pframe.add(mainp,"main")
clayout.show(pframe, "main")
}
public void actionPerformed(ActionEvent e){
if(e.getSource() == jm21 || e.getSource() == jb1){
if(ip == null){
ip= new InsertPanel()
pframe.add(ip,"insert")
}
clayout.show(pframe, "insert")
this.setTitle("输入学生信息")
}
else if(e.getSource() == jm22 || e.getSource() == jb2){
if(sp == null){
sp= new SelectPanel()
pframe.add(sp,"select")
}
clayout.show(pframe, "select")
this.setTitle("查询学生信息")
}
else if(e.getSource() == jm11 || e.getSource() == jb3){
System.exit(0)
}
}
}
第二个:
import javax.swing.Jframe
public class MainTest {
public static void main(String [] args){
Mainframe f = new Mainframe("学生信息管理平台")
f.setSize(400,300)
f.setLocation(350,250)
f.setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE)
f.setVisible(true)
}
}
第二个:
import java.sql.Connection
import java.sql.DriverManager
public class MySQLConnection {
static Connection getCon(){
Connection con = null
try{
Class.forName("com.mysql.jdbc.Driver")
con = DriverManager.getConnection("jdbc:mysql://localhost/test","root","123")
}
catch(Exception e){
System.out.println("建立数据库连接遇到异常!")
}
return con
}
}
第四个:
import java.awt.BorderLayout
import java.awt.GridLayout
import java.awt.event.ActionEvent
import java.awt.event.ActionListener
import javax.swing.JButton
import javax.swing.JLabel
import javax.swing.JOptionPane
import javax.swing.JPanel
import javax.swing.JTextField
import javax.swing.SwingConstants
public class SelectPanel extends JPanel implements ActionListener{
JButton jb
JTextField jt
JTextField jt1,jt2,jt3,jt4
public SelectPanel(){
JLabel jl = new JLabel("请输入学号:",SwingConstants.CENTER)
jt = new JTextField()
jb = new JButton("确定")
JPanel jp1 = new JPanel(new GridLayout(1,3))
jp1.add(jl)
jp1.add(jt)
jp1.add(jb)
JLabel j1,j2,j3,j4
j1 = new JLabel("学号:",SwingConstants.CENTER)
j2 = new JLabel("姓名:",SwingConstants.CENTER)
j3 = new JLabel("性别:",SwingConstants.CENTER)
j4 = new JLabel("年龄:",SwingConstants.CENTER)
jt1 = new JTextField(6)
jt1.setEditable(false)
jt2 = new JTextField(6)
jt2.setEditable(false)
jt3 = new JTextField(6)
jt3.setEditable(false)
jt4 = new JTextField(6)
jt4.setEditable(false)
JPanel jp2 = new JPanel(new BorderLayout())
JPanel jp3 = new JPanel(new GridLayout(4,2))
jp2.add(new JLabel(""),BorderLayout.NORTH)
jp3.add(j1)
jp3.add(jt1)
jp3.add(j2)
jp3.add(jt2)
jp3.add(j3)
jp3.add(jt3)
jp3.add(j4)
jp3.add(jt4)
jp2.add(jp3)
this.setLayout(new BorderLayout())
add(jp1,BorderLayout.NORTH)
add(jp2)
jb.addActionListener(this)
}
public void actionPerformed(ActionEvent e){
if(e.getSource() == jb){
String stuNo = jt.getText().trim()
Student s = new Student()
boolean b = true
try{
b = s.selectByStuNo(stuNo)
}
catch(Exception ex){
System.out.println("查询学生信息遇到异常!")
}
if(b){
jt1.setText(s.getStuNo())
jt2.setText(s.getName())
jt3.setText(s.getGender())
int a = s.getAge()
Integer i = new Integer(a)
jt4.setText(i.toString())
}
else{
JOptionPane.showMessageDialog(null, "无此学生!")
}
}
}
}
第五个:
import javax.swing.Jframe
public class SelectTest {
public static void main(String [] args){
Jframe f = new Jframe("查询学生信息")
SelectPanel p = new SelectPanel()
f.add(p)
f.setSize(400,300)
f.setLocation(300,250)
f.setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE)
f.setVisible(true)
}
}
第六个:
import java.sql.Connection
import java.sql.ResultSet
import java.sql.Statement
public class Student {
String stuNo
String name
String gender
int age
public Student(){}
public Student(String stuNo,String name,String gender, int age){
this.stuNo = stuNo
this.name = name
this.gender = gender
this.age = age
}
public String getStuNo(){
return stuNo
}
public void setStuNo(String stuNo){
this.stuNo = stuNo
}
public String getName(){
return name
}
public void setName(String name){
this.name = name
}
public String getGender(){
return gender
}
public void setGender(String gender){
this.gender = gender
}
public int getAge(){
return age
}
public void setAge(int age){
this.age = age
}
public boolean insertStudent(){
boolean b = true
try{
Connection con = MySQLConnection.getCon()
Statement statement = con.createStatement()
String sql = "insert into student values('" + stuNo + "','" + name +"','" + gender + "'," + age + ")"
sql = new String(sql.getBytes("gb2312"),"ISO8859_1")
statement.executeUpdate(sql)
con.close()
}
catch(Exception e){
b = false
System.out.println("插入数据库遇到异常!")
}
return b
}
public boolean selectByStuNo(String stuNo)throws Exception{
boolean b = true
Connection con = MySQLConnection.getCon()
Statement statement = con.createStatement()
String sql = "select * from student where stuNo =" + stuNo
ResultSet rs = statement.executeQuery(sql)
if(rs != null &&rs.next()){
String no = rs.getString(1)
this.setStuNo(no)
String n = rs.getString(2)
n = new String(n.getBytes("ISO8859_1"),"gb2312")
this.setName(n)
String g = rs.getString(3)
g = new String (g.getBytes("ISO8859_1"),"gb2312")
this.setGender(g)
this.setAge(rs.getInt(4))
b = true
}
rs.close()
statement.close()
con.close()
return b
}
}
数据库你自己弄吧,我没时间弄了!初学得多动手哦
简单的设定:
以下程序默认条件:
该表单仅有一个用户:用户名和密码均为数值型123456
用户名文本框名字为text1,密码文本框的名字是text2
那么登陆表单的确定按钮代码可以设置为:
if alltrim(thisform.text1.value)==123456 and alltrim(thisform.text2.value)==123456
messagebox("欢迎使用,登陆成功!",0,"提示信息")
else
messagebox("用户名或者密码错误!请重新输入!",0,"错误信息")
endif
thisform.refresh
以上就是关于学生成绩管理系统的代码是什么?全部的内容,如果了解更多相关内容,可以关注,你们的支持是我们更新的动力!
版权声明:我们致力于保护作者版权,注重分享,被刊用文章【idea教务管理系统代码】因无法核实真实出处,未能及时与作者取得联系,或有版权异议的,请联系管理员,我们会立即处理! 部分文章是来自自研大数据AI进行生成,内容摘自(百度百科,百度知道,头条百科,中国民法典,刑法,牛津词典,新华词典,汉语词典,国家院校,科普平台)等数据,内容仅供学习参考,不准确地方联系删除处理!;
工作时间:8:00-18:00
客服电话
电子邮件
beimuxi@protonmail.com
扫码二维码
获取最新动态
