[英]solve through a loop in java
I have a text box(having name b)
and one submit button in index.jsp
. 我在
index.jsp
有一个text box(having name b)
和一个提交按钮。 I will enter something in text box then after clicking submit
i get that value by in server side find.jsp
. 我将在文本框中输入内容,然后单击“
submit
”,然后在服务器端find.jsp
获得该值。 In find.jsp i get the value by request.getParameter("b");
在find.jsp中,我通过
request.getParameter("b");
获取值request.getParameter("b");
In find.jsp
calaculation is done as shown below: 在
find.jsp
计算如下所示:
double c=0;
double d=0;
7800.0/12 and 2640.0/12 are fixed.
if request.getParameter("b")=1 then
c=7800.0/12*5;// 5 is multiplied with above number(in first one)
d=2640.0/12*5;// 5 is multiplied with above number(in second one)
if request.getParameter("b")=2 then
c=7800.0/12*8;// here 5 gets incremented by 3 and became 8(in first one)
d=2640.0/12*8;// same also here( in second one)
Similarly if i will enter 20 then accordingly c and d will be calculated. 同样,如果我输入20,则将相应地计算c和d。 I cannot use if-else as any value can be entered in client side and accordingly c and d will be calculated in server side.
我不能使用if-else,因为可以在客户端输入任何值,因此c和d将在服务器端计算。 How can i implement it in a loop?
我怎样才能在循环中实现它? Many thanks
非常感谢
try 尝试
double devide=2.0
devide = Integer.parseInt(request.getParameter("b"))*3+devide
c=7800.0/(12*devide);
d=2640.0/(12*devide);
You can use for any value to count below one logic. 您可以使用任何值来计算低于一个逻辑。
int value = Integer.parseInt(request.getParameter("b"));
double x=2.0;
double valueForDevide = (value*3)+x;
c=7800.0/(12*valueForDevide );
d=2640.0/(12*valueForDevide );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.