aasdfasdfasdfasdfasdf
This commit is contained in:
37
Assignments/JavaScript/ch05/ch05/ex_5_5.html
Executable file
37
Assignments/JavaScript/ch05/ch05/ex_5_5.html
Executable file
@@ -0,0 +1,37 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Example 5.5</title>
|
||||
<script>
|
||||
function floatToInteger()
|
||||
{
|
||||
var floatNum = 0; var newValue = 0;
|
||||
var change = " ";
|
||||
floatNum = prompt("Enter any number or enter -99 to quit:", "");
|
||||
while (floatNum != -99)
|
||||
{
|
||||
document.write("<p>You originally entered: " + floatNum + "</p>");
|
||||
newValue = parseInt(floatNum);
|
||||
document.write("<p>The result of pareseInt(X) is: " + newValue + "</p>");
|
||||
newValue = Math.floor(floatNum);
|
||||
document.write("<p>The result of Math.floor(X) is : " + newValue + "</p>");
|
||||
newValue = Math.ceil(floatNum);
|
||||
document.write("<p>The result of Math.ceil(X) is : " + newValue + "</p>");
|
||||
newValue = Math.round(floatNum);
|
||||
document.write("<p>The result of Math.round(X) is : " + newValue + "</p>");
|
||||
floatNum = prompt("Enter any number or enter -99 to quit:", "");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<table align ="center" width ="70%"><tr><td colspan ="2">
|
||||
<h1> </h2>
|
||||
<h1>Using Math Methods to Convert Floating Point Numbers to Integers</h1>
|
||||
<tr><td><p> </p>
|
||||
<p><input type="button" id="integers" value="Begin" onclick="floatToInteger();" /></p>
|
||||
</td></tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user