代码如下:
<%@ include file="article.jsp"%>
<%
String race_id=request.getParameter("race_id");
String project_id=request.getParameter("project_id");
String number1=request.getParameter("number");
String p1=request.getParameter("page");
if(race_id==null)
{
response.sendRedirect("error.htm");
}
else if(project_id==null)
{
response.sendRedirect("error.htm");
}
else if(number1==null)
{
response.sendRedirect("error.htm");
}
else if(p1==null)
{
response.sendRedirect("error.htm");
}
int number=Integer.parseInt(number1);
int p=Integer.parseInt(p1);
ResultSet rt=stmt.executeQuery("select * from race where race_id='"+race_id+"'");
rt.next();
String n1=rt.getString("n");
int n=Integer.parseInt(n1);
int a;
double sc[];
sc=new double[9];
double score_1=0.0,score_2=0.0,score_3=0.0,score_4=0.0,score_5=0.0,score_6=0.0,score_7=0.0,score_8=0.0,score_9=0.0;
for(a=1;a<n+1;a++)
{
switch(a)
{
case 1: score_1=Double.parseDouble(request.getParameter("score_1"));sc[0]=score_1;break;
case 2: score_2=Double.parseDouble(request.getParameter("score_2"));sc[1]=score_2;break;
case 3: score_3=Double.parseDouble(request.getParameter("score_3"));sc[2]=score_3;break;
case 4: score_4=Double.parseDouble(request.getParameter("score_4"));sc[3]=score_4;break;
case 5: score_5=Double.parseDouble(request.getParameter("score_5"));sc[4]=score_5;break;
case 6: score_6=Double.parseDouble(request.getParameter("score_6"));sc[5]=score_6;break;
case 7: score_7=Double.parseDouble(request.getParameter("score_7"));sc[6]=score_7;break;
case 8: score_8=Double.parseDouble(request.getParameter("score_8"));sc[7]=score_8;break;
case 9: score_9=Double.parseDouble(request.getParameter("score_9"));sc[8]=score_9;break;
default: rt.close();
stmt.close();
conn.close();
response.sendRedirect("error1.htm");
}
}
double add=Double.parseDouble(request.getParameter("add"));
double jian=Double.parseDouble(request.getParameter("jian"));
String miao1=request.getParameter("miao");
int miao=Integer.parseInt(miao1);
double max1=0.0,max2=0.0,min1=11.0,min2=11.0,fact_score=0.0,end_score=0.0;
int m1=0,m2=0;
//ÏÂÃæÊÇÑ¡³ö×î´óºÍ×îСµÄ·ÖÊý
if(n<=5)
{
for(a=0;a<n;a++)
{
fact_score=((double)((int)(fact_score*100)+(int)(sc[a]*100)))/100;
if(max1<sc[a])
{
max1=sc[a];
m1=a;
}
if(min1>sc[a])
{
min1=sc[a];
m2=a;
}
}
fact_score=((double)((int)(fact_score*100)-(int)(max1*100)-(int)(min1*100)))/(100*(n-2));
end_score=((double)((int)(fact_score*100)+(int)(add*100)-(int)(jian*100)))/100;
}
else
{
for(a=0;a<n;a++)
{
fact_score=((double)((int)(fact_score*100)+(int)(sc[a]*100)))/100;
if(max1<sc[a])
{
max1=sc[a];
m1=a;
}
if(min1>sc[a])
{
min1=sc[a];
m2=a;
}
}
//ÏÂÃæÑ¡³öµÚ¶þ´óºÍµÚ¶þСµÄÊý
for(a=0;a<n;a++)
{
if(m1==a)
{}
else if(m2==a)
{}
else
{
if(max2<sc[a])
{
max2=sc[a];
}
if(min2>sc[a])
{
min2=sc[a];
}
}
}
fact_score=((double)((int)(fact_score*100)-(int)(max1*100)-(int)(min1*100)-(int)(max2*100)-(int)(min2*100)))/((n-4)*100);
end_score=((double)((int)(fact_score*100)+(int)(add*100)-(int)(jian*100)))/100;
}
switch(n)
{
case 1:stmt.executeUpdate("update score set score_1='"+score_1+"',fact_score='"+fact_score+"',end_score='"+end_score+"',miao='"+miao+"' where race_id='"+race_id+"' and project_id='"+project_id+"' and number='"+number+"'");
case 2:stmt.executeUpdate("update score set score_1='"+score_1+"',score_2='"+score_2+"',fact_score='"+fact_score+"',end_score='"+end_score+"',miao='"+miao+"' where race_id='"+race_id+"' and project_id='"+project_id+"' and number='"+number+"'");
case 3:stmt.executeUpdate("update score set score_1='"+score_1+"',score_2='"+score_2+"',score_3='"+score_3+"',fact_score='"+fact_score+"',end_score='"+end_score+"',miao='"+miao+"' where race_id='"+race_id+"' and project_id='"+project_id+"' and number='"+number+"'");
case 4:stmt.executeUpdate("update score set score_1='"+score_1+"',score_2='"+score_2+"',score_3='"+score_3+"',score_4='"+score_4+"',fact_score='"+fact_score+"',end_score='"+end_score+"',miao='"+miao+"' where race_id='"+race_id+"' and project_id='"+project_id+"' and number='"+number+"'");
case 5:stmt.executeUpdate("update score set score_1='"+score_1+"',score_2='"+score_2+"',score_3='"+score_3+"',score_4='"+score_4+"',score_5='"+score_5+"',fact_score='"+fact_score+"',end_score='"+end_score+"',miao='"+miao+"' where race_id='"+race_id+"' and project_id='"+project_id+"' and number='"+number+"'");
case 6:stmt.executeUpdate("update score set score_1='"+score_1+"',score_2='"+score_2+"',score_3='"+score_3+"',score_4='"+score_4+"',score_5='"+score_5+"',score_6='"+score_6+"',fact_score='"+fact_score+"',end_score='"+end_score+"',miao='"+miao+"' where race_id='"+race_id+"' and project_id='"+project_id+"' and number='"+number+"'");
case 7:stmt.executeUpdate("update score set score_1='"+score_1+"',score_2='"+score_2+"',score_3='"+score_3+"',score_4='"+score_4+"',score_5='"+score_5+"',score_6='"+score_6+"',score_7='"+score_7+"',fact_score='"+fact_score+"',end_score='"+end_score+"',miao='"+miao+"' where race_id='"+race_id+"' and project_id='"+project_id+"' and number='"+number+"'");
case 8:stmt.executeUpdate("update score set score_1='"+score_1+"',score_2='"+score_2+"',score_3='"+score_3+"',score_4='"+score_4+"',score_5='"+score_5+"',score_6='"+score_6+"',score_7='"+score_7+"',score_8='"+score_8+"',fact_score='"+fact_score+"',end_score='"+end_score+"',miao='"+miao+"' where race_id='"+race_id+"' and project_id='"+project_id+"' and number='"+number+"'");
case 9:stmt.executeUpdate("update score set score_1='"+score_1+"',score_2='"+score_2+"',score_3='"+score_3+"',score_4='"+score_4+"',score_5='"+score_5+"',score_6='"+score_6+"',score_7='"+score_7+"',score_8='"+score_8+"',score_9='"+score_9+"',fact_score='"+fact_score+"',end_score='"+end_score+"',miao='"+miao+"' where race_id='"+race_id+"' and project_id='"+project_id+"' and number='"+number+"'");
}
rt.close();
stmt.close();
conn.close();
response.sendRedirect("score.jsp");
%>
<%@ include file="article.jsp"%>
<%
String race_id=request.getParameter("race_id");
String project_id=request.getParameter("project_id");
String number1=request.getParameter("number");
String p1=request.getParameter("page");
if(race_id==null)
{
response.sendRedirect("error.htm");
}
else if(project_id==null)
{
response.sendRedirect("error.htm");
}
else if(number1==null)
{
response.sendRedirect("error.htm");
}
else if(p1==null)
{
response.sendRedirect("error.htm");
}
int number=Integer.parseInt(number1);
int p=Integer.parseInt(p1);
ResultSet rt=stmt.executeQuery("select * from race where race_id='"+race_id+"'");
rt.next();
String n1=rt.getString("n");
int n=Integer.parseInt(n1);
int a;
double sc[];
sc=new double[9];
double score_1=0.0,score_2=0.0,score_3=0.0,score_4=0.0,score_5=0.0,score_6=0.0,score_7=0.0,score_8=0.0,score_9=0.0;
for(a=1;a<n+1;a++)
{
switch(a)
{
case 1: score_1=Double.parseDouble(request.getParameter("score_1"));sc[0]=score_1;break;
case 2: score_2=Double.parseDouble(request.getParameter("score_2"));sc[1]=score_2;break;
case 3: score_3=Double.parseDouble(request.getParameter("score_3"));sc[2]=score_3;break;
case 4: score_4=Double.parseDouble(request.getParameter("score_4"));sc[3]=score_4;break;
case 5: score_5=Double.parseDouble(request.getParameter("score_5"));sc[4]=score_5;break;
case 6: score_6=Double.parseDouble(request.getParameter("score_6"));sc[5]=score_6;break;
case 7: score_7=Double.parseDouble(request.getParameter("score_7"));sc[6]=score_7;break;
case 8: score_8=Double.parseDouble(request.getParameter("score_8"));sc[7]=score_8;break;
case 9: score_9=Double.parseDouble(request.getParameter("score_9"));sc[8]=score_9;break;
default: rt.close();
stmt.close();
conn.close();
response.sendRedirect("error1.htm");
}
}
double add=Double.parseDouble(request.getParameter("add"));
double jian=Double.parseDouble(request.getParameter("jian"));
String miao1=request.getParameter("miao");
int miao=Integer.parseInt(miao1);
double max1=0.0,max2=0.0,min1=11.0,min2=11.0,fact_score=0.0,end_score=0.0;
int m1=0,m2=0;
//ÏÂÃæÊÇÑ¡³ö×î´óºÍ×îСµÄ·ÖÊý
if(n<=5)
{
for(a=0;a<n;a++)
{
fact_score=((double)((int)(fact_score*100)+(int)(sc[a]*100)))/100;
if(max1<sc[a])
{
max1=sc[a];
m1=a;
}
if(min1>sc[a])
{
min1=sc[a];
m2=a;
}
}
fact_score=((double)((int)(fact_score*100)-(int)(max1*100)-(int)(min1*100)))/(100*(n-2));
end_score=((double)((int)(fact_score*100)+(int)(add*100)-(int)(jian*100)))/100;
}
else
{
for(a=0;a<n;a++)
{
fact_score=((double)((int)(fact_score*100)+(int)(sc[a]*100)))/100;
if(max1<sc[a])
{
max1=sc[a];
m1=a;
}
if(min1>sc[a])
{
min1=sc[a];
m2=a;
}
}
//ÏÂÃæÑ¡³öµÚ¶þ´óºÍµÚ¶þСµÄÊý
for(a=0;a<n;a++)
{
if(m1==a)
{}
else if(m2==a)
{}
else
{
if(max2<sc[a])
{
max2=sc[a];
}
if(min2>sc[a])
{
min2=sc[a];
}
}
}
fact_score=((double)((int)(fact_score*100)-(int)(max1*100)-(int)(min1*100)-(int)(max2*100)-(int)(min2*100)))/((n-4)*100);
end_score=((double)((int)(fact_score*100)+(int)(add*100)-(int)(jian*100)))/100;
}
switch(n)
{
case 1:stmt.executeUpdate("update score set score_1='"+score_1+"',fact_score='"+fact_score+"',end_score='"+end_score+"',miao='"+miao+"' where race_id='"+race_id+"' and project_id='"+project_id+"' and number='"+number+"'");
case 2:stmt.executeUpdate("update score set score_1='"+score_1+"',score_2='"+score_2+"',fact_score='"+fact_score+"',end_score='"+end_score+"',miao='"+miao+"' where race_id='"+race_id+"' and project_id='"+project_id+"' and number='"+number+"'");
case 3:stmt.executeUpdate("update score set score_1='"+score_1+"',score_2='"+score_2+"',score_3='"+score_3+"',fact_score='"+fact_score+"',end_score='"+end_score+"',miao='"+miao+"' where race_id='"+race_id+"' and project_id='"+project_id+"' and number='"+number+"'");
case 4:stmt.executeUpdate("update score set score_1='"+score_1+"',score_2='"+score_2+"',score_3='"+score_3+"',score_4='"+score_4+"',fact_score='"+fact_score+"',end_score='"+end_score+"',miao='"+miao+"' where race_id='"+race_id+"' and project_id='"+project_id+"' and number='"+number+"'");
case 5:stmt.executeUpdate("update score set score_1='"+score_1+"',score_2='"+score_2+"',score_3='"+score_3+"',score_4='"+score_4+"',score_5='"+score_5+"',fact_score='"+fact_score+"',end_score='"+end_score+"',miao='"+miao+"' where race_id='"+race_id+"' and project_id='"+project_id+"' and number='"+number+"'");
case 6:stmt.executeUpdate("update score set score_1='"+score_1+"',score_2='"+score_2+"',score_3='"+score_3+"',score_4='"+score_4+"',score_5='"+score_5+"',score_6='"+score_6+"',fact_score='"+fact_score+"',end_score='"+end_score+"',miao='"+miao+"' where race_id='"+race_id+"' and project_id='"+project_id+"' and number='"+number+"'");
case 7:stmt.executeUpdate("update score set score_1='"+score_1+"',score_2='"+score_2+"',score_3='"+score_3+"',score_4='"+score_4+"',score_5='"+score_5+"',score_6='"+score_6+"',score_7='"+score_7+"',fact_score='"+fact_score+"',end_score='"+end_score+"',miao='"+miao+"' where race_id='"+race_id+"' and project_id='"+project_id+"' and number='"+number+"'");
case 8:stmt.executeUpdate("update score set score_1='"+score_1+"',score_2='"+score_2+"',score_3='"+score_3+"',score_4='"+score_4+"',score_5='"+score_5+"',score_6='"+score_6+"',score_7='"+score_7+"',score_8='"+score_8+"',fact_score='"+fact_score+"',end_score='"+end_score+"',miao='"+miao+"' where race_id='"+race_id+"' and project_id='"+project_id+"' and number='"+number+"'");
case 9:stmt.executeUpdate("update score set score_1='"+score_1+"',score_2='"+score_2+"',score_3='"+score_3+"',score_4='"+score_4+"',score_5='"+score_5+"',score_6='"+score_6+"',score_7='"+score_7+"',score_8='"+score_8+"',score_9='"+score_9+"',fact_score='"+fact_score+"',end_score='"+end_score+"',miao='"+miao+"' where race_id='"+race_id+"' and project_id='"+project_id+"' and number='"+number+"'");
}
rt.close();
stmt.close();
conn.close();
response.sendRedirect("score.jsp");
%>
解决方案 »
- js中easyui-combobox赋值
- ssh集成,将jsp文件放在webRoot的某个目录文件夹下找不到action?急
- 初学jsp 用include传递参数时中文乱码
- 谁帮忙给来一个jfreechart例子
- jsp聊天室的自动刷新问题!
- 抽象类中的非抽象方法是否可以覆盖?怎么覆盖?马上给分
- linux下weblogic启动后出现问题,进来看看!
- jsp页面显示太慢了,有什么优化tomcat 或IE的方法吗?谢谢了
- jsp如何读取txt,Excel文件?
- jbuilder8中如何在web目录建一个文件夹?
- 在线等 ,怎样用 JSP 调用另一个 JSP啊,我以前看到过,忘了,请帮忙。。
- 空指针问题
while(rt.next()){
//取得所需要的值
}
while(rt.next()){
//取得所需要的值
}判断什么??