Java課程設計—學生成績管理系統(201521123005 楊雪瑩)

1、團隊課程設計博客連接

學生成績管理系統html

2、我的負責模塊或任務說明

  • 學生成績錄入
  • 顯示全部學生信息
  • 顯示各科平均成績
  • 顯示學生成績(按降序排序)

3、本身的代碼提交記錄截圖

4、本身負責模塊或任務詳細說明

1.學生成績錄入首先要選擇所要錄入的科目,而後須要先從數據庫裏得到學生的學號及姓名,每錄入一個成績須要確認,確認後才又從數據庫讀取信息,繼續錄入成績,達到界面的比較美觀java

下面是一開始的Java成績錄入的界面
sql

而後錄入成績
數據庫

確認後界面顯示
jsp

再錄入一個成績
ide

確認後顯示
post

主要代碼:學習

<%
        <%
        StudentDao student = new StudentDaoJDBC();
        List<Student> studentList=student.findAllStudent();
        for(Student e:studentList)
        {
            String score=String.valueOf(e.getMath());
            //out.println(score);
        %>
        <form name="postForm" action="EnterStudentMathScore.jsp" " method="post">
        <tr>
            <td><input type="text" id="a" name="stuno"
                value=<%=e.getStuno()%> readonly="true"></td>
            <td><input type="text" id="stuname" name="stuname"
                value=<%=e.getName() %> readonly="true"></td>

        </tr>
        <%
        String stscore =request.getParameter("stuscore"); 
        String stno =request.getParameter("stuno");
        StudentDao sdao=new StudentDaoJDBC();
        int s = sdao.addStudentScore(stno,"math",stscore);
        Student stu=sdao.findBystuno(e.getStuno());
        double math=stu.getMath();
        double score1=math+e.getSport()+e.getJava();
        String stuno =String.valueOf(e.getStuno());
        String score2=String.valueOf(score1);
        int s1 = sdao.addStudentScore(stuno,"allscore",score2);
        %>
        <td><input type="text" id="stuscore" name="stuscore"
                value=<%=math%>></td>
        <input type="submit" value="確認" /><br>
        </form>
        <% 
        
          }
           %>

2.顯示學生各科平均成績,主要是用了數據的語句就能夠很方便的獲取
界面:
設計

主要代碼:3d

@Override
        public double getCourseAv(String course) {
            // TODO Auto-generated method stub
            Connection conn = null;
            Statement stat = null;
            ResultSet rs = null;
            double avscore=0.0;
            String sql = "select  avg("+course+")  from students";//表中有id和name這列
            try {
                conn = JDBCUtil.getConnection();
                stat = conn.createStatement();
                rs = stat.executeQuery(sql);
                while(rs.next()){
                    avscore=rs.getDouble("avg("+course+")");
                }
            }catch (SQLException sqle) {
                sqle.printStackTrace();
            }catch(Exception e){
                e.printStackTrace();
            }finally{
                JDBCUtil.realeaseAll(rs,stat, conn);
            }
            return avscore;
        }

3.顯示學生全部信息,比較簡單就不詳細講
界面:

主要代碼:

 

4.顯示學生成績按成績降序排序,也是主要用"select * from students order by allscore desc" sql語句
界面:

主要代碼:

public List<Student> showSortAchievement() {
            // TODO Auto-generated method stub
            Connection conn = null;
            Statement stat = null;
            ResultSet rs = null;
            Student stu=null;
            List<Student> students=new ArrayList<Student>();
            String sql = "select * from students order by allscore desc";
            try {
                conn = JDBCUtil.getConnection();
                stat = conn.createStatement();
                rs = stat.executeQuery(sql);
                while(rs.next()){
                    stu=new Student(rs.getInt("stuno"),rs.getString("name"),
                            rs.getDouble("math"),rs.getDouble("sport"),rs.getDouble("java"),rs.getDouble("allscore"));
                    students.add(stu);
                }
            }catch (SQLException sqle) {
                sqle.printStackTrace();
            }catch(Exception e){
                e.printStackTrace();
            }finally{
                JDBCUtil.realeaseAll(rs,stat, conn);
            }
            return students;
        }

5、課程設計感想

此次課設時間比較趕,感受時間再多一點能夠寫得更完善。課設設計過程對java,數據庫,Jsp的學習有很到的幫助,能寫出本身想要的效果仍是很開心的。我寫錄入成績,寫了好久,能夠後真的很開心,以爲熬夜沒有白費了!通過此次課設,就但願課設的時候沒有考試!!這樣就不用寫得那麼趕,還能夠完善頁面一下,能夠作更多的容錯處理
相關文章
相關標籤/搜索