⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 crouse_score.java

📁 本网站为学生管理网站
💻 JAVA
字号:
package students;
import java.sql.*;
public class Crouse_score {
	public static int[] fun(String str){
		Connection con=null;
		Statement stmt=null;
		ResultSet rs = null;
		int score[]=new int [6];
		
		try{
		
			con = Database.connectToDb();
			String strSQL2="select S.degree from sel_crouses S where S.cro_id= "+str;
			stmt = con.createStatement();
			rs = stmt.executeQuery(strSQL2);
			while(rs.next()){
				if(Float.parseFloat(rs.getString("degree"))<60)
					score[0]++;
				else if(Float.parseFloat(rs.getString("degree"))>=60 && Float.parseFloat(rs.getString("degree"))<70)
					score[1]++;
				else if(Float.parseFloat(rs.getString("degree"))>=70 && Float.parseFloat(rs.getString("degree"))<80)
					score[2]++;
				else if(Float.parseFloat(rs.getString("degree"))>=80 && Float.parseFloat(rs.getString("degree"))<90)
					score[3]++;
				else if(Float.parseFloat(rs.getString("degree"))>=90 && Float.parseFloat(rs.getString("degree"))<100)
					score[4]++;
				else if(Float.parseFloat(rs.getString("degree"))==100)
					score[5]++;
			}
		}catch (SQLException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (con != null) {
				try {
					con.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
				con = null;
			}
		}
		return score;
	}
	public static float fun1(String str){
		Connection con=null;
		Statement stmt=null;
		ResultSet rs = null;
		int i=0;
		float result=0;
		float res=0;
		try{
		
			con = Database.connectToDb();
			String strSQL2="select S.degree from sel_crouses S where S.cro_id= "+str;
			stmt = con.createStatement();
			rs = stmt.executeQuery(strSQL2);
			while(rs.next()){
				result+=Float.parseFloat(rs.getString("degree"));
				i++;
			}
		}catch (SQLException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (con != null) {
				try {
					con.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
				con = null;
			}
		}
		res=result/i;
//		java.text.DecimalFormat df = new java.text.DecimalFormat("#.00");   
//		df.format(res);
		return res;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -