묻고답하기
page_full_width" class="col-xs-12" |cond="$__Context->page_full_width">
[JSP] 계산기 입니다. -- 작동이 안되네여.. 도와주세여~~
2003.03.17 20:45
<%@ page contentType="text/html; charset=euc-kr" %>
<html>
<head>
<title>계산기</title>
</head>
<% String a = "0";
String b = "0";
int result = 0;
String radio;
if (request.getQueryString() != null && request.getQueryString() != ""){
a = request.getParameter("a");
b = request.getParameter("b");
radio = request.getParameterValues("radio");
switch (radio){
case 1 :
result = Integer.parseInt(a) + Integer.parseInt(b);
break;
case 2 :
result = Integer.parseInt(a) - Integer.parseInt(b);
break;
case 3 :
result = Integer.parseInt(a) * Integer.parseInt(b)
break;
case 4 :
result = Integer.parseInt(a) / Integer.parseInt(b)
break;
}
}
%>
<body><form method = "post" action = "col.jsp">
하고자 하는 연산 선택
<p> </p>
<form action="col.jsp" method="post" name="form1" target="_self">
<p> FIRST :
<input name="a" type="text" id="a" value="0">
</p>
<p>
<input name="radio" type="radio" value="1" checked>
더하기
<input type="radio" name="radio" value="2">
빼기
<input type="radio" name="radio" value="3">
곱하기
<input type="radio" name="radio" value="4">
나누기 </p>
<p> SECOND :
<input name="b" type="text" id="b" value="0">
</p>
<p>RESULT :
<input name="result" type="text" id="result" value="<%= result %>">
</p>
<p>
<input name="submit" type = "submit" value = "연산">
<input type="reset" name="Reset" value="Reset">
</p>
</form>
</body>
</html>
<html>
<head>
<title>계산기</title>
</head>
<% String a = "0";
String b = "0";
int result = 0;
String radio;
if (request.getQueryString() != null && request.getQueryString() != ""){
a = request.getParameter("a");
b = request.getParameter("b");
radio = request.getParameterValues("radio");
switch (radio){
case 1 :
result = Integer.parseInt(a) + Integer.parseInt(b);
break;
case 2 :
result = Integer.parseInt(a) - Integer.parseInt(b);
break;
case 3 :
result = Integer.parseInt(a) * Integer.parseInt(b)
break;
case 4 :
result = Integer.parseInt(a) / Integer.parseInt(b)
break;
}
}
%>
<body><form method = "post" action = "col.jsp">
하고자 하는 연산 선택
<p> </p>
<form action="col.jsp" method="post" name="form1" target="_self">
<p> FIRST :
<input name="a" type="text" id="a" value="0">
</p>
<p>
<input name="radio" type="radio" value="1" checked>
더하기
<input type="radio" name="radio" value="2">
빼기
<input type="radio" name="radio" value="3">
곱하기
<input type="radio" name="radio" value="4">
나누기 </p>
<p> SECOND :
<input name="b" type="text" id="b" value="0">
</p>
<p>RESULT :
<input name="result" type="text" id="result" value="<%= result %>">
</p>
<p>
<input name="submit" type = "submit" value = "연산">
<input type="reset" name="Reset" value="Reset">
</p>
</form>
</body>
</html>