»
EnglishFrenchVietnamese

Print - Area/Volume Generator - JavaScriptBank.com

Full version: jsB@nk » Calculation » Math » Area/Volume Generator
URL: https://www.javascriptbank.com/area-volume-generator.html

Area/Volume Generator © JavaScriptBank.comNeed to find the area or circumference of a circle, the area of a rectangle, or the volume of a cylinder? This cool script will find it for you. In addition to the answer, it also gives all the steps needed to solve the equation. (The answer is rounded off.) Pretty cool!

Full version: jsB@nk » Calculation » Math » Area/Volume Generator
URL: https://www.javascriptbank.com/area-volume-generator.html



JavaScript
<SCRIPT LANGUAGE="JavaScript">// Craig Blanchette (Sk8dogg4@aol.com)<!-- Beginfunction findarea(){radius = document.FORM1.areainput.value;radius2 = eval(radius*radius);answer = eval(Math.PI*Math.pow(radius,2))roundanswer = Math.round(answer);document.FORM1.codegenerator.value = 'A = PIR^2\r'+'A = PI x '+radius+'*'+radius+' \r'+'A = PI x '+radius2+'\r'+'A = '+answer+' \r'+'A = '+roundanswer;}function findcircum(){radiuscir = document.FORM1.areainput.value;diameter = eval(radiuscir*2);ciranswer = eval(radiuscir*2*Math.PI);cirRoundanswer = Math.round(ciranswer);document.FORM1.codegenerator.value = 'C = 2PIR\r'+'C = PI x 2 x '+radiuscir+' \r'+'C = PI x '+diameter+' \r'+'C = '+ciranswer+' \r'+'C = '+cirRoundanswer;}function rectarea(){side1 = document.FORM1.rect1.value;side2 = document.FORM1.rect2.value;rectanswer = eval(side1*side2);roundrect = Math.round(rectanswer);document.FORM1.codegenerator.value = 'A = B x H\r'+'A = '+side1+' x '+side2+' \r'+'A = '+rectanswer+' \r'+'A = '+roundrect}function cylarea(){cylradius = document.FORM1.areainput.value;sqradius = eval(cylradius*cylradius);cylheight = document.FORM1.cylinderheight.value;cylhr = eval(cylheight*sqradius);cylvolume = eval(Math.PI*cylradius*cylradius*cylheight);roundcyl = Math.round(cylvolume);document.FORM1.codegenerator.value = 'V = PIR^2H\r'+'V = PI x '+cylradius+' x '+cylradius+' x H \r'+'V = PI x '+sqradius+' x H\r'+'V = PI x '+sqradius+' x '+cylheight+' \r'+'V = PI x '+cylhr+' \r'+'V = '+cylvolume+' \r'+'V = '+roundcyl;}function resetval(){document.FORM1.areainput.value = 'Radius of Cirlce/Cylinder';document.FORM1.codegenerator.value = '';document.FORM1.cylinderheight.value = 'Height of Cylinder';document.FORM1.rect1.value = 'Base';document.FORM1.rect2.value = 'Height';}// End --></script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<form name="FORM1"><font face="Arial, Helvetica, Sans Serif" size="3"color="#0000FF"><b>Enter Radius of Circle/Cylinder</b></font><br><input type="text"size="15" name="areainput" onfocus="this.value=''"><br><input type="button" name="findcircumference" onclick="findcircum()"value="Get Circumference"><input type="button" name="findarea2" onclick="findarea()"value="Get Area"><p><font face="Arial, Helvetica, Sans Serif" size="3"color="#0000FF"><b>Enter Height of Cylinder</b></font><br><input type="text"name="cylinderheight" onfocus="this.value=''" size="20"><br><input type="button" name="cylinderarea" value="Get volumeof Cylinder" onclick="cylarea()"><br>(<i>Make sure you entered the radius</i>)<p><font face="Arial, Helvetica, Sans Serif" size="3"color="#0000FF"><b>The calculation and answer is below:</b></font><br><textarea name="codegenerator" rows="10" cols="30"></textarea><p><font face="Arial, Helvetica, Sans Serif" size="3"color="#0000FF"><b>Enter Measurments for Rectangle Area:</b></font><br><input type="text" name="rect1" value="Base"onfocus="this.value=''" size="20"><br><input type="text" name="rect2" value="Height"onfocus="this.value=''" size="20"><br><input type="button" name="findcircumference"onclick="rectarea()" value="Get Area">.<br><input type="button" name="reset" value="Reset"onclick="resetval()"></form><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->