换钱小问题,问题已写,求指教?
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%><html>
<body>
<form action="money.jsp">
<table>
<tr>
<td>应付款:</td>
<td><input name="number" type="text"></td>
</tr>
<tr>
<td>实际付款:</td>
<td><input name="number1" type="text"></td>
</tr>
</table>
<input type="submit" value="提交">
</form>
</body>
</html>
**********************************************************************************************************************
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
<body>
<%
String s1 = request.getParameter("number");
String s2 = request.getParameter("number1");
double m1 = -1;
double m2 = -1;
double m3 = -1;
int i=0;
if (s1 !=null && s2 !=null) //这个地方输的是数字并不能判断是不是为空,怎样判断输入的是不是数字
{
m1 = Double.parseDouble(s1);
m2 = Double.parseDouble(s2);
if (m1 >= 0 && m2 >= 0&&m2>=m1)//这个地方也判断不了m2是否大于m1,m2是必须要大于m1的
{
int y100, y50, y10, y5, y;
m3 = m2 - m1;
for (y = 0; y <= m3; y++) {
for (y5 = 0; y5 <= m3 / 5; y5++) {
for (y10 = 0; y10 <= m3 / 10; y10++) {
for (y50 = 0; y50 <= m3 / 50; y50++) {
for (y100=0;y100<=m3/100;y100++) {
if(y+y5*5+y10*10+y50*50+y100*100==m3){
out.println("应该付 :"+"100元"+y100+"张"+","+"50元"+y50+"张"+","+"10元"+y10+"张"+","+
"5元"+y5+"张"+","+"1元"+y+"张"+"<br>");
i++;
}
}
}
}
}
}
}
else{
out.println("你应付的金额不足");
}
out.println("总共有:"+i+"种换法");
}
else{
out.println("输入有误,请重新输入:");//我想让输入错误转回money1.jsp怎么弄
}
%>
<jsp:forward page="money1.jsp"/>
</body>
</html>