当前位置: 代码迷 >> Java相关 >> 求编写这个程序
  详细解决方案

求编写这个程序

热度:463   发布时间:2010-11-18 23:20:47.0
求编写这个程序
我自己写这个程序已经写了很久了还是不大会,应为我们的Java课程对图形界面老师将的太少,考试不要求,现在我们课程结束了,想请教高人来谢谢啊!

学生成绩管理系统。该系统主要用于对学生的成绩进行综合管理,学生成绩至少包含下面的要素:学期、学号、姓名、课程名称、课程成绩。因此学生成绩管理系统的主要功能为:
1 学生信息管理
2 课程信息管理
3 成绩信息管理
4 学期信息管理
要求:
1.    学生执行“选课”操作
2.    系统显示所有的课程信息,包括两项:课程编号、课程名称
3.    学生选择其中的课程,并提交
4.    系统为该学生添加选课记录到选课信息文件,并提示选课成功。
限制条件:
1.    当系统中的课程信息为空时,要给出没有课程可选的提示信息,此时学生不能选课
2.    选课满足下列条件才能成功:所选的课程确实存在于课程信息文件中,同一名学生不能重复选同一门课
当教师登录截面的时候:
登录
用例描述:教师凭个人的工号进入系统,以使用系统功能。
活动步骤:
1.    系统运行,给出登录界面
2.    教师输入个人工号,选用“教师”身份登录
3.    系统检查工号是否正确,如果有误,不允许进入系统,并给出错误提示;如果正确,则显示教师用户的操作界面。

用例名称:录入成绩
活动步骤:
1.    教师执行“录入成绩”操作
2.    系统给出录入界面
3.    教师录入成绩,并提交
4.    系统保存成绩到选课信息文件,并提示录入成功
其他条件:
系统要采取措施保证满足下面条件才能添加成绩:确实存在该名学生、确实存在该门课程、该学生确实选了该门课。

用例名称:按学生查看成绩
用例描述:查看某一学生所有课程的成绩
活动步骤:
1.    教师执行“按学生查看成绩”操作
2.    教师输入(或者选择)某个姓名
3.    系统显示拥有该名字的学生的所有已选课程的成绩信息,包括5项:学号、姓名、课程号、课程名、成绩。如果不存在该学生,则提示没有该学生;如果不存在该学生的任何一条选课信息,则提示该学生没有选课

搜索更多相关的解决方案: 编写  

----------------解决方案--------------------------------------------------------
团队合作的部分程序,求论坛中的高人继续下面的程序

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class A extends JFrame implements ActionListener
{      
    private static final long serialVersionUID = 1L;
         private JButton b1;
         private JButton b2 ;
         private JButton b3 ;
         private JButton b4 ;
         static JTextField f1;
         private JPasswordField f2;
    public A() throws IOException{        
         super("登陆系统");                           
         setLayout(new GridLayout(4, 2,8,8));
         JLabel l1 = new JLabel("学(工)号:");
         f1= new JTextField(12);
         JLabel l2 = new JLabel("密码:");
         f2=new JPasswordField(16);
         b1 = new JButton("学生登录");         b2 = new JButton("老师登录");         
         b3 = new JButton("退出");            b4 = new JButton("学生注册");
         add(l1);      add(f1);      add(l2);     add(f2);
         add(b1);      add(b2);      add(b4);     add(b3);     
         b1.addActionListener(this);
         b2.addActionListener(this);
         b3.addActionListener(this);
         b4.addActionListener(this);
         setBounds(300,300,360,240);
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         setVisible(true);
         
         File file2=new File("D:\\myfolder");
         file2.mkdir();  
         
         File file9=new File("D:\\myfolder\\teacher.txt");  
         file9.createNewFile();
         File file23=new File("D:\\myfolder\\teacherdenglu.txt");  
         file23.createNewFile();
         File file20=new File("D:\\myfolder\\studentname.txt");  
         file20.createNewFile();
         File file11=new File("D:\\myfolder\\studentscore.txt");  
          file11.createNewFile();
          File file8=new File("D:\\myfolder\\yixuancourse.txt");  
           file8.createNewFile();
           File file10=new File("D:\\myfolder\\student.txt");         
          file10.createNewFile();
         
         FileWriter file12=new FileWriter("D:\\myfolder\\teacher.txt",true);
         BufferedWriter bf5=new BufferedWriter(file12);   
         try{
         FileReader file1=new FileReader("D:\\myfolder\\teacher.txt");
         BufferedReader bf=new BufferedReader(file1);
         String s4 = bf.readLine();    int flag=0;   
         while(s4!=null)
            {                                            
            if(s4.indexOf("老师:张老师   工号:001") != -1)                             
               flag=1;   
               s4=bf.readLine();                                                                                                               
           }                              
             if(flag==0)
           bf5.write("老师:张老师   工号:001");   
             bf5.newLine();
            bf5.close();
                    
         
             FileReader file15=new FileReader("D:\\myfolder\\student.txt");
             BufferedReader bfg=new BufferedReader(file15);            
             String s5 = bfg.readLine();    int flag1=0;   
             while(s5!=null)
                {                                            
                if(s5.indexOf("学号:001  密码:123456") != -1)                             
                   flag1=1;   
                   s5=bfg.readLine();                                                                                                                 
               }                              
                 if(flag1==0)   
                     try{
                        FileWriter file16=new FileWriter("D:\\myfolder\\student.txt");
                        BufferedWriter bf6=new BufferedWriter(file16);   
                        bf6.write("姓名:小王  学号:001  密码:123456"+"\r\n"+"姓名:小明  学号:002  密码:123456"+"\r\n"+"姓名:小张  学号:003  密码:123456");                                             
                        bf6.close();
                     }catch (IOException e1) { e1.printStackTrace(); }   
                 
                 FileWriter file24=new FileWriter("D:\\myfolder\\teacherdenglu.txt");
                 BufferedWriter bf11=new BufferedWriter(file24);   
              FileReader file25=new FileReader("D:\\myfolder\\teacherdenglu.txt");
                 BufferedReader bfa=new BufferedReader(file25);            
                 String s9 = bfg.readLine();    int flag3=0;   
                 while(s9!=null)
                    {                                            
                    if(s9.indexOf("姓名:张老师  学号:001  密码:123456") != -1)                             
                       flag3=1;   
                       s9=bfa.readLine();                                                                                                           
                   }                              
                     if(flag3==0)               
                   bf11.write("姓名:张老师  学号:001  密码:123456");
                     bf11.newLine();
                     bf11.close();
                     
                    
              FileReader file22=new FileReader("D:\\myfolder\\studentname.txt");
                 BufferedReader bfgg=new BufferedReader(file22);            
                 String s8 = bfgg.readLine();    int flag2=0;   
                 while(s8!=null)
                    {                                            
                    if(s8.indexOf("学生:小王  学号:001") != -1)                             
                       flag2=1;   
                       s8=bfgg.readLine();                                                                                                            
                   }                              
                     if(flag2==0)
                         try{
                         FileWriter file21=new FileWriter("D:\\myfolder\\studentname.txt");
                     BufferedWriter bf10=new BufferedWriter(file21);
                   bf10.write("学生:小王  学号:001"+"\r\n"+"学生:小明  学号:002"+"\r\n"+"学生:小张  学号:003");              
                     bf10.close();
                     }catch (IOException e1) { e1.printStackTrace(); }               
           }catch (IOException e1) { e1.printStackTrace(); }        
        }   
public void actionPerformed(ActionEvent e)
        {
            if( e.getSource()==b1)
             {      
                 try {                                                            
                      FileReader ff = new FileReader("D:\\myfolder\\student.txt");               
                      BufferedReader bf=new BufferedReader(ff);   
                      String s = bf.readLine();
                                  int flag=0;
                                while(s!=null)   
                                 {   
                                    if(s.indexOf(f1.getText().trim()) != -1  &&s.indexOf(new String(f2.getPassword()))!= -1 )
                                    flag=1;      s=bf.readLine();
                                     }bf.close();
                    if(f1.getText().trim().equals("")){
                          JOptionPane.showMessageDialog(null,"\t请输入用户名!","用户名空提示",JOptionPane.OK_OPTION);
                           }                                          
                          else if(new String(f2.getPassword()).equals("")){
                           JOptionPane.showMessageDialog(null,"\t请输入密码!","密码空提示",JOptionPane.OK_OPTION);}                                                   
                                else if(flag==1)
                                {  
                               student a=new student();//进入学生选课界面   
                                  a.student();      dispose();   
                                     }                                                                                               
                                   else if(flag==0){                                                                    
                              JOptionPane.showMessageDialog(null,"\t用户名或密码错误,请重新输入!","提示",JOptionPane.OK_OPTION);}         
                         }catch (IOException e1) { e1.printStackTrace(); }                                                     
            }
             else if( e.getSource()==b2)
             {      
                 try {                                                            
                     FileReader ff = new FileReader("D:\\myfolder\\teacherdenglu.txt");               
                    BufferedReader bf=new BufferedReader(ff);   
                      String s = bf.readLine();
                                  int flag=0;
                                while(s!=null)   
                                 {   
                                    if(s.indexOf(f1.getText().trim()) != -1  &&s.indexOf(new String(f2.getPassword())) != -1 )
                                    flag=1;      s=bf.readLine();  break;
                                     }
                    if(f1.getText().trim().equals("")){
                          JOptionPane.showMessageDialog(null,"\t请输入用户名!","用户名空提示",JOptionPane.OK_OPTION);
                           }                                          
                          else if(new String(f2.getPassword()).equals("")){
                           JOptionPane.showMessageDialog(null,"\t请输入密码!","密码空提示",JOptionPane.OK_OPTION);}                                                   
                                else if(flag==1)
                                {  
                                 teacher a=new teacher();//进入老师界面   
                                  a.teacher();      dispose();   
                                     }                                                                                               
                                   else{                                                                    
                              JOptionPane.showMessageDialog(null,"\t用户名或密码错误,请重新输入!","提示",JOptionPane.OK_OPTION);}         
                         }catch (IOException e1) { e1.printStackTrace(); }                                                     
            }
            else if(e.getSource()==b3)
             {
                   System.exit(0);
            }      
            else if(e.getSource()==b4)
            {
                final JFrame d=new JFrame("学生注册");            
                 d.setLayout(new GridLayout(5, 2,8,8));
                 JButton bb1=new JButton("确定");
                 JButton bb2=new JButton("取消");
                 final JTextField ff1=new  JTextField(12);
                 final JTextField ff2=new  JTextField(12);         
                 final JPasswordField ff3=new  JPasswordField(12);
                 final JPasswordField ff4=new  JPasswordField(12);     
                 JLabel l1 = new JLabel("请输入姓名:");
                 JLabel l2 = new JLabel("请输入学号:");   
                 JLabel l3 = new JLabel("请输入登陆密码:");
                 JLabel l4 = new JLabel("请输入登陆密码:");
                 d.add(l1);     d.add(ff1);     d.add(l2);      d.add(ff2);
                 d.add(l3);     d.add(ff3);     d.add(l4);      d.add(ff4);
                 d.add(bb1);     d.add(bb2);
                     bb1.addActionListener(new ActionListener(){//内部类
                          public void actionPerformed(final ActionEvent e){
                             int flag=0;  
                              try{
                                  FileReader file1=new FileReader("D:\\myfolder\\student.txt");
                                 BufferedReader bf=new BufferedReader(file1);
                                 String s4 = bf.readLine();      
                                 while(s4!=null)
                                    {                                            
                                    if(s4.indexOf(ff2.getText())!= -1)                             
                                       flag=1;   
                                       s4=bf.readLine();          break;                                                                                                        
                                   }                              
                              }catch (IOException e1) { e1.printStackTrace();}
                              if(flag==0)
                              {
                                if((new String(ff3.getPassword())).equals(new String(ff4.getPassword())))
                                   {
                                   try{
                                   FileWriter file1=new FileWriter("D:\\myfolder\\studentname.txt",true);
                                      BufferedWriter bf=new BufferedWriter(file1);                                
                                      bf.write("姓名:"+ff1.getText()+"   学号:"+ff2.getText());   
                                      bf.newLine();
                                      bf.close();   
                                      FileWriter file2=new FileWriter("D:\\myfolder\\student.txt",true);
                                      BufferedWriter bff=new BufferedWriter(file2);                                         
                                      bff.write("姓名:"+ff1.getText()+"   学号:"+ff2.getText()+"密码:"+new String(ff3.getPassword()));                                    
                                      bff.newLine();
                                      bff.close();                                 
                                      JOptionPane.showMessageDialog(null, "注册成功", "提示", JOptionPane.ERROR_MESSAGE);
                                      d.dispose();
                                   }catch (IOException e1) { e1.printStackTrace();}
                                  }
                                else
                                   {
                                   JOptionPane.showMessageDialog(null, "您两次输入的密码不一致,请重新输入", "提示",  JOptionPane.ERROR_MESSAGE);
                                   }   
                              }
                              else if(flag==1)
                              {
                                  JOptionPane.showMessageDialog(null, "这个账号已经注册过了,请重新注册", "提示",  JOptionPane.ERROR_MESSAGE);
                              }
                    }});   
                    bb2.addActionListener(new ActionListener(){//内部类
                         public void actionPerformed(final ActionEvent e){
                              d.dispose();
                     }});   
                                          d.setBounds(300,300,360,240);
                                          d.dispose();
                                          d.setVisible(true);
           }         
      }
public static void main(String[] args) throws IOException
        {
       new A();
        }
}

----------------解决方案--------------------------------------------------------
不是不写!

--确实有点不想写

JAVA大部分应用都是基于B/S的,建议你将这个程序修改为B/S结构的!

对你很有益处!
----------------解决方案--------------------------------------------------------
LZ,其实图形界面可以用IDE自动生成, 不用写得这么费力。
你写出界面后,还要接连数据库,“增删改查”。。。。
----------------解决方案--------------------------------------------------------
我现在都在用swt弄图形界面,awt不大想用。。
----------------解决方案--------------------------------------------------------
回复 3楼 elan1986
我们学的少,没办法啊
----------------解决方案--------------------------------------------------------
你的程序可算得上一个小项目了, 里面包含的程序很多, 并不是一两天就学会的
----------------解决方案--------------------------------------------------------
  相关解决方案