Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <!-- round.html Karen Zhu-->
- <!-- Web page that rounds a number to one decimal place. -->
- <html>
- <head>
- <title> Number Rounder </title>
- </head>
- <body>
- <h2> Number Rounder </h2>
- <p>
- Enter a number: <input type="text" id="numberBox" size=12 value="">
- Number of digits to round to: <input type="text" id="roundBox" size=12 value="">
- </p>
- <input type="button" value="Round It"
- onclick="number=parseFloat(document.getElementById('numberBox').value);
- numberOfDigits=parseFloat(document.getElementById('roundBox').value);
- multiplier=10^numberOfDigits;
- rounded=Math.round(multiplier*number)/multiplier;
- document.getElementById('outputDiv').innerHTML=
- number + ' rounded to roundBox ' + rounded;">
- <hr>
- <div id="outputDiv"></div>
- </body>
- </html>
Add Comment
Please, Sign In to add comment