/* 간단한 계산기 프로그램 */
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Calculator</title>
</head>
<body>
<center>
<table>
<tr>
<td>
<form name="Calculator">
<input type="text" name="answer" size="20" value="">
</form>
</td>
</tr>
</table>
<table>
<tr valign="top">
<td><input type="button" name="times" value=" * "
onClick="document.Calculator.answer.value += '*'"></td>
<td><input type="button" name="divided" value=" / "
onClick="document.Calculator.answer.value += '/'"></td>
<td><input type="button" name="minus" value=" - "
onClick="document.Calculator.answer.value += '-'"></td>
<td><input type="button" name="clear" value=" C "
onClick="document.Calculator.answer.value = ''"></td>
</tr>
<tr valign="top">
<td><input type="button" name="seven" value=" 7 "
onClick="document.Calculator.answer.value += '7'"></td>
<td><input type="button" name="eight" value=" 8 "
onClick="document.Calculator.answer.value += '8'"></td>
<td><input type="button" name="nine" value=" 9 "
onClick="document.Calculator.answer.value += '9'"></td>
<td><input type="button" name="zero" value=" 0 "
onClick="document.Calculator.answer.value += '0'"></td>
</tr>
<tr>
<td><input type="button" name="four" value=" 4 "
onClick="document.Calculator.answer.value += '4'"></td>
<td><input type="button" name="five" value=" 5 "
onClick="document.Calculator.answer.value += '5'"></td>
<td><input type="button" name="six" value=" 6 "
onClick="document.Calculator.answer.value += '6'"></td>
<td><input type="button" name="equals" value=" = "
onClick="document.Calculator.answer.value = eval(document.Calculator.answer.value)"></td>
</tr>
<tr>
<td><input type="button" name="one" value=" 1 "
onClick="document.Calculator.answer.value += '1'"></td>
<td><input type="button" name="two" value=" 2 "
onClick="document.Calculator.answer.value += '2'"></td>
<td><input type="button" name="three" value=" 3 "
onClick="document.Calculator.answer.value += '3'"></td>
<td><input type="button" name="plus" value=" + "
onClick="document.Calculator.answer.value += '+'"></td>
</tr>
</table>
</center>
</body>
</html>
result)
댓글 없음:
댓글 쓰기