【发布时间】:2013-06-04 14:39:43
【问题描述】:
我需要在java中计算bmi 到目前为止我有这个代码
input_page.jsp
<form action="calc_bmi.jsp" method="post">
<table>
<tr>
<td>height:</td>
<td><input type="text" name="height" size="35" maxlength="6" ></td>
</tr>
<tr>
<td>weight:</td>
<td><input type="text" name="weight" size="35" maxlength="6" ></td>
</tr>
<tr>
<td colspan="2"><input type="button" onclick="formReset()" value="reset">
<input type="submit" value="submit"></td>
</tr>
</table>
</form>
calc_bmi.jsp
<%
String wt=request.getParameter("weight");
String ht=request.getParameter("height");
double weight=Integer.parseInt(wt);
double height=Integer.parseInt(ht);
double w=weight;
double h=height*height;
double bmi = w/h;
out.println("BMI of weight "+weight+" and height "+height+" is: "+bmi);
%>
我怎样才能接受体重和身高字段中的小数?
谢谢
【问题讨论】: