In this article I would like to a share with you guys a simple program that will ask the use give the area of the circle and then our program will compute the area of the circle using JavaScript as our programming language.
Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
Sample Program Output
Program Listing
<html>
<title> Area of a Circle Solver 1.0
</title>
<body bgcolor="lightgreen">
<font color="red" face="Arial" size="5">
<center>
<br>
Area of a Circle Solver 1.0
<br>
</center>
</font>
<style type="text/css">
.labelText {
text-align : right;
padding-right : 3px;
color : red;
font-family:"Arial";
font-size : 18px;
}
</style>
<form name="circle" method="post">
<table>
<tr>
<tr>
<td> </td>
</tr>
<td class="labelText"> What is the area of the circle
</td>
<td> <input type="text" name="area" size="10"/> </td>
</tr>
<tr>
<td> </td>
</tr>
</td>
<tr>
<td class="labelText">
The result is
</td>
<td>
<input type="text" name="display" size="50"/> </td>
</tr>
<tr>
<td> </td>
</tr>
</td>
<td> <input type="button" value="Compute"
title="Click here to compute the area of the circle."
onClick="compute1()">
</td>
<td> <input type="button" value="Clear"
title="Click here to clear the text box."
onClick="clear_all()">
</td>
</table>
</font>
</form>
<script language ="javascript">
function compute1()
{
var xval1, solve1,final_result;
var result;
value1 = parseInt(document.circle.area.value);
solve1 = (3.14159 * value1 * value1);
// For two decimal places convertion
final_result = Math.round(solve1 * 100) /100;
result = value1 + " radius is equivalent to "
+ final_result + " area of the circle. ";
document.circle.display.value = result;
}
function clear_all()
{
document.circle.area.value = "";
document.circle.display.value = "";
document.circle.area.focus();
}
</script>
</body>
</html>
No comments:
Post a Comment