java删除学生成绩代码 java中删除学生信息的代码-成都快上网建站

java删除学生成绩代码 java中删除学生信息的代码

java问题,我抱着万分之一的希望来问下,程序如下,走一遍没问题,加了while(true){……}之后就出现异常

给你改了下,你看能不能用。你用while语句还是要注意的while true是死循环,你里面数组长度就是10.到了自然报错,不然你改成3.4。5这种数试试。后面的删除自己再写吧,我就给你写了添加

成都创新互联是创新、创意、研发型一体的综合型网站建设公司,自成立以来公司不断探索创新,始终坚持为客户提供满意周到的服务,在本地打下了良好的口碑,在过去的10年时间我们累计服务了上千家以及全国政企客户,如成都人造雾等企业单位,完善的项目管理流程,严格把控项目进度与质量监控加上过硬的技术实力获得客户的一致称扬。

stuMark am=new stuMark();

int num=0;    

int i=0;

Scanner sn=new Scanner(System.in);

System.out.print("请选择你要执行的操作:1.输入并存储学生成绩 5.通过学号删除学生成绩");

num=sn.nextInt();

Scanner sc=new Scanner(System.in);

while(iam.index){

float mark=0;

System.out.println("请输入学号为"+i+"的学生的成绩:");

mark=sc.nextFloat();

am.inMark(mark,i);

i++;

}

for (float d:am.arr) {

System.out.println(d);

}

学生管理系统的删除学生信息 删除代码请修改一下。。急需帮助。。马上就要交作业了

import java.awt.event.*;

import javax.swing.*;

import java.awt.*;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;

public class DeleteFrame extends JFrame implements ActionListener {

private MainFrame parentF;

JTextField jt1=new JTextField();

JTextField jt2=new JTextField();

JTextField JTextField_free=new JTextField();

JButton jb=new JButton("删除");

JOptionPane JOptionPane1 = new JOptionPane();

public DeleteFrame(MainFrame m){

super("删除学生信息 ");

parentF=m;

this.setSize( 400,250);

this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

Container c=this.getContentPane();

c.setLayout(null);

JLabel j1=new JLabel("学 号");

JLabel j2=new JLabel("姓 名");

c.add(j1);

j1.setBounds(10,10,60,30);

c.add(jt1);

jt1.setBounds(70,10,100,30);

c.add(j2);

j2.setBounds(200,10,60,30);

c.add(jt2);

jt2.setBounds(250,10,100,30);

c.add(jb);

jb.setBounds(100,180,60,40);

jb.addActionListener(this);

this.addWindowListener(new WindowAdapter(){

public void windowClosing(WindowEvent e){

parentF.setVisible(true);

shutDown();

}

});

}

public void shutDown(){

this.dispose();

}

public void deleteRecord(int id){

try{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

}

catch(ClassNotFoundException ex){

System.exit(-1);

}

try{

String URL="jdbc:odbc:student1";

Connection con =DriverManager.getConnection(URL);

Statement stmt1=con.createStatement();

String SQL="delete from 成绩表 where id = " + id;

ResultSet rs=stmt1.executeQuery(SQL);

System.out.println(stmt1);

stmt1.close();

con.close();

JTextField_free.setText("");

JOptionPane1.showMessageDialog(this,"删除成功","消息",

JOptionPane.INFORMATION_MESSAGE);

}

catch(SQLException ex){

ex.printStackTrace();

}

}

public void actionPerformed(ActionEvent e){

if(e.getSource()==jb){

this.deleteRecord(id);//id为所删记录的主键值

}

}

}

用java写一个学生成绩管理系统程序,且有增加,查询,修改,删除,要求在控制台显示

我这边有个可视化编程的 当初的上机实验 可采纳

import java.awt.*;

import java.awt.event.*;

public class Test extends Frame implements TextListener,ItemListener,ActionListener,WindowListener

{

static TextArea ta1=new TextArea(" ",10,1,TextArea.SCROLLBARS_NONE);

static TextArea ta2=new TextArea(" ",10,1,TextArea.SCROLLBARS_NONE);

static Checkbox chk_g1=new Checkbox("男");

static Checkbox chk_g2=new Checkbox("女");

static Checkbox g=new Checkbox();

static Choice cho1=new Choice();

static Choice cho2=new Choice();

static Button bun1=new Button("增加");

static Button bun2=new Button("删除");

static List lst=new List();

static Test frm=new Test();

public static void main(String[] args)

{

Test frm=new Test();

CheckboxGroup grp=new CheckboxGroup();

frm.setLayout(null);

frm.setTitle("学生信息输入窗口");

frm.setBounds(100,100,400,400);

lst.setBounds(10,50,180,300);

ta1.setBounds(210,50,180,20);

ta2.setBounds(210,100,180,20);

chk_g1.setBounds(210,150,80,40);

chk_g2.setBounds(300,150,80,40);

cho1.setBounds(210,200,180,40);

cho2.setBounds(210,250,180,40);

bun1.setBounds(210,300,80,40);

bun2.setBounds(300,300,80,40);

chk_g1.setCheckboxGroup(grp);

chk_g2.setCheckboxGroup(grp);

cho1.add("计算机科学与技术");

cho1.add("金融系");

cho2.add("金融理财");

cho2.add("软件工程");

cho2.add("网络技术");

frm.setBackground(Color.lightGray);

ta1.setBackground(Color.lightGray);

ta2.setBackground(Color.lightGray);

lst.setBackground(Color.lightGray);

chk_g1.setBackground(Color.lightGray);

chk_g2.setBackground(Color.lightGray);

cho1.setBackground(Color.lightGray);

cho2.setBackground(Color.lightGray);

bun1.setBackground(Color.lightGray);

bun2.setBackground(Color.lightGray);

frm.add(ta1);

frm.add(ta2);

frm.add(chk_g1);

frm.add(chk_g2);

frm.add(cho1);

frm.add(cho2);

frm.add(bun1);

frm.add(bun2);

frm.add(lst);

ta1.addTextListener(frm);

ta2.addTextListener(frm);

chk_g1.addItemListener(frm);

chk_g2.addItemListener(frm);

cho1.addItemListener(frm);

cho2.addItemListener(frm);

bun1.addActionListener(frm);

bun2.addActionListener(frm);

lst.addItemListener(frm);

frm.addWindowListener(frm);

frm.setVisible(true);

}

public void windowOpened(WindowEvent e){}

public void windowActivated(WindowEvent e){}

public void windowIconified(WindowEvent e){}

public void windowDeiconified(WindowEvent e){}

public void windowClosing(WindowEvent e)

{

frm.dispose();

System.exit(0);

}

public void windowDeactivated(WindowEvent e){}

public void windowClosed(WindowEvent e){}

public void textValueChanged(TextEvent e)

{

}

public void itemStateChanged(ItemEvent e)

{

}

public void actionPerformed(ActionEvent e)

{

Button but=(Button)e.getSource();

if(but==bun1)

{

String text1=ta1.getText();

String text2=ta2.getText();

String c1=cho1.getSelectedItem();

String c2=cho2.getSelectedItem();

if(chk_g1.getState())

{

lst.add(text1+" "+text2+" "+chk_g1.getLabel()+" "+c1+" "+c2);

}

else if(chk_g2.getState())

{

lst.add(text1+" "+text2+" "+chk_g2.getLabel()+" "+c1+" "+c2);

}

}

else if(but==bun2)

{

String B=lst.getSelectedItem();

lst.remove(B);

}

}

}

基于java设计一个学生成绩管理系统,要求有界面,且有增加,查询,修改,删除,退出功能,代码如何写?

import java.awt.Color;

import java.awt.Font;

import java.awt.Frame;

import java.awt.Label;

import java.awt.TextField;

import java.awt.Window;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.WindowAdapter;

import java.awt.event.WindowEvent;

import java.sql.SQLException;

import javax.swing.JButton;

public class Stmessege {

Font font = new Font("楷体", Font.BOLD, 18);

private Frame m = new Frame("登陆成功界面");

protected Window f;

public Stmessege() {

m.addWindowListener(new WindowAdapter() {

public void windowClosing(WindowEvent evt) {

m.setVisible(false);

m.dispose();

System.exit(0);

}

});

m.setSize(460, 360);

m.setBackground(Color.green);

m.setLayout(null);

m.setLocationRelativeTo(null);

Label l0 = new Label("管理员信息");

Font font1 = new Font("楷体", Font.BOLD, 32);

l0.setForeground(Color.blue);

l0.setSize(180, 50);

l0.setLocation(150, 30);

l0.setFont(font1);

final Label l1 = new Label("姓名:");

l1.setSize(60, 20);

l1.setLocation(10, 100);

l1.setFont(font);

TextField tf1 = new TextField("黄朋");

tf1.setForeground(Color.blue);

tf1.setBackground(Color.white);

tf1.setSize(50, 20);

tf1.setLocation(70, 100);

final Label l2 = new Label("学号:");

l2.setSize(60, 20);

l2.setLocation(140, 100);

l2.setFont(font);

TextField tf2 = new TextField("111265");

tf2.setForeground(Color.blue);

tf2.setBackground(Color.white);

tf2.setSize(60, 20);

tf2.setLocation(190, 100);

final Label l3 = new Label("性别:");

l3.setSize(60, 20);

l3.setLocation(280, 100);

l3.setFont(font);

TextField tf3 = new TextField("男");

tf3.setForeground(Color.blue);

tf3.setBackground(Color.white);

tf3.setSize(40, 20);

tf3.setLocation(360, 100);

final Label l4 = new Label("班级:");

l4.setSize(60, 20);

l4.setLocation(10, 170);

l4.setFont(font);

TextField tf4 = new TextField("611231");

tf4.setForeground(Color.blue);

tf4.setBackground(Color.white);

tf4.setSize(60, 20);

tf4.setLocation(67, 170);

final Label l5 = new Label("系别:");

l5.setSize(60, 20);

l5.setLocation(140, 170);

l5.setFont(font);

TextField tf5 = new TextField("计算机工程系");

tf5.setForeground(Color.blue);

tf5.setBackground(Color.white);

tf5.setSize(80, 20);

tf5.setLocation(200, 170);

final Label l6 = new Label("成绩:");

l6.setSize(60, 20);

l6.setLocation(280, 170);

l6.setFont(font);

TextField tf6 = new TextField("95");

tf6.setForeground(Color.blue);

tf6.setBackground(Color.white);

tf6.setSize(40, 20);

tf6.setLocation(360, 170);

final Label l7 = new Label("专业:");

l7.setSize(60, 20);

l7.setLocation(10, 230);

l7.setFont(font);

TextField tf7 = new TextField("软件技术");

tf7.setForeground(Color.blue);

tf7.setBackground(Color.white);

tf7.setSize(60, 20);

tf7.setLocation(70, 230);

JButton btn1 = new JButton("添加");

btn1.setForeground(Color.blue);

btn1.setSize(80, 38);

btn1.setLocation(35, 300);

btn1.setFont(font);

btn1.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent e) {

// TODO Auto-generated method stub

new 插入();

m.setVisible(true);

}

});

JButton btn2 = new JButton("查询学生学籍信息");

btn2.setForeground(Color.blue);

btn2.setSize(200, 38);

btn2.setLocation(135, 300);

btn2.setFont(font);

btn2.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

Stmessege1 f;

try {

f = new Stmessege1();

f.Stmessege11();

m.setVisible(true);

} catch (SQLException e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

} catch (ClassNotFoundException e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

}

}

});

JButton btn3 = new JButton("删除");

btn3.setForeground(Color.blue);

btn3.setSize(80, 38);

btn3.setLocation(350, 300);

btn3.setFont(font);

btn3.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent e) {

// TODO Auto-generated method stub

new 删除();

//f.setVisible(false);

m.setVisible(true);

}

});

JButton btn4 = new JButton("更新");

btn4.setForeground(Color.blue);

btn4.setSize(80, 38);

btn4.setLocation(200, 230);

btn4.setFont(font);

btn4.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent e) {

// TODO Auto-generated method stub

new 更新();

m.setVisible(true);

}

});

m.add(l0);

m.add(l1);

m.add(tf1);

m.add(l2);

m.add(tf2);

m.add(l3);

m.add(tf3);

m.add(l4);

m.add(tf4);

m.add(l5);

m.add(tf5);

m.add(l6);

m.add(tf6);

m.add(l7);

m.add(tf7);

m.add(btn1);

m.add(btn2);

m.add(btn3);

m.add(btn4);

m.setVisible(true);

}

public static void main(String[] args) {

new Stmessege();

}

}

可以仿照我的做一下,希望采纳,我才一级哦


新闻标题:java删除学生成绩代码 java中删除学生信息的代码
文章起源:http://kswjz.com/article/dopjjsi.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流