float a = rs.getFloat("C"); float b = rs.getFloat("java"); float c = rs.getFloat("english"); System.out.println(rs.getString("sno") + "\t"+ rs.getString("sname") + "\t" + a + "\t" + b + "\t" + c + "\t" + ((a + b + c ) / 4)); } ; // 输出平均分 System.out.println("\n各科平均分\n\nC语言\tJAVA\t英语\t"); rs = stmt.executeQuery("select avg(C),avg(java),avg(english) from lxh1"); while (rs.next()) { System.out.println(rs.getInt(1) + "\t" + rs.getInt(2) + "\t" + rs.getInt(3) + "\t" + rs.getInt(4)); } ; // 输出最高分 System.out.println("\n各科最高分\n\nC\t英语\tJAVA\t计算机\t"); rs = stmt.executeQuery("select max(math),max(english),max(java),max(computer) from lxh1"); while (rs.next()) { System.out.println(rs.getInt(1) + "\t" + rs.getInt(2)+ rs.getInt(3) + "\t" + rs.getInt(4)); } ; // 输出最低分 System.out.println("\n各科最低分\n\nC语言\tJAVA\t英语\t"); rs = stmt.executeQuery("select min(C),min(java),min(english) from lxh1"); while (rs.next()) { System.out.println(rs.getInt(1) + "\t" + rs.getInt(2) + "\t" + rs.getInt(3) + "\t" + rs.getInt(4)); } ; break; case 0: break; default: System.out.println("感谢您的使用,再见!"); } stmt.close(); con.close(); }} // TODO code application logic here
添加回答
举报
0/150
提交
取消