topical media & game development

talk show tell print

basic-javascript-04-ch4-examp3.htm / htm



  <html>
  <body>
  <script language="JavaScript" type="text/javascript">
  
  var myNumber = prompt("Enter the number to be rounded","");
  
  document.write("<h3>The number you entered was " + myNumber + "</h3><br>");
  document.write("<p>The rounding results for this number are</p>");
  document.write("<table width=150 border=1>");
  document.write("<tr><th>Method</th><th>Result</th></tr>");
  document.write("<tr><td>parseInt()</td><td>"+ parseInt(myNumber) +"</td></tr>");
  document.write("<tr><td>ceil()</td><td>" + Math.ceil(myNumber) + "</td></tr>");
  document.write("<tr><td>floor()</td><td>"+ Math.floor(myNumber) + "</td></tr>");
  document.write("<tr><td>round()</td><td>" + Math.round(myNumber) +"</td></tr>");
  document.write("</table>")
  
  </script>
  </body>
  </html>
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.