»
EnglishFrenchVietnamese

Print - Calculator Version 1.0 - JavaScriptBank.com

Full version: jsB@nk » Calculation » Calculator » Calculator Version 1.0
URL: https://www.javascriptbank.com/calculator-version-1.html

Calculator Version 1.0 © JavaScriptBank.comThis is a very sharp looking advanced calculator code made using JavaScript and HTML.

Full version: jsB@nk » Calculation » Calculator » Calculator Version 1.0
URL: https://www.javascriptbank.com/calculator-version-1.html



JavaScript
<script language="javascript"><!--// Designed by David Tinoco. Copyright (c) 2001 by David Tinoco.// arithmatical functionsfunction add(){var addend1 = eval(prompt("First number:"));var addend2 = eval(prompt("Second number:"));var sum = addend1 + addend2;alert("Your sum is " + sum);}function subtract(){var first = eval(prompt("First number:"));var second = eval(prompt("Second number:"));var sum = first - second;alert("Your answer is " + sum);}function multiply(){var factor1 = eval(prompt("First factor:"));var factor2 = eval(prompt("Second factor:"));var product = factor1 * factor2;alert("Your product is " + product);}function divide(){var dividend = eval(prompt("Dividend:"));var divisor = eval(prompt("Divisor:"));var divide = dividend / divisor;alert("Your quotient is " + divide);}// decimal and fractional functionsfunction percentage(){var percent = eval(prompt("Percentage:"));var num = eval(prompt("The number of which you will find the percent:"));var change = percent / 100;var times = change * num;alert(percent + "% of " + num + " = " + times);}function fractToDec(){var numer = eval(prompt("Numerator:"));var denom = eval(prompt("Denominator:"));var change1 = numer / denom;alert(numer + "/" + denom + " = " + change1);}//perimeter functionsfunction perimSquare(){var unit = prompt("Unit of measurement:");var side1 = eval(prompt("Length of one side:"));var cal = side1 * 4;alert("Your answer is " + cal + " " + unit);}function perimRect(){var unit = prompt("Unit of measurement:");var side1 = eval(prompt("Length:"));var side2 = eval(prompt("Width:"));var cal1 = side1 * 2;var cal2 = side2 * 2;var sum_it = cal1 + cal2;alert("Your answer is " + sum_it + " " + unit);}function perimTri(){var unit = prompt("Unit of measurement:");var side1 = eval(prompt("Side 1:"));var side2 = eval(prompt("Side 2:"));var side3 = eval(prompt("Side 3:"));var cal1 = side1 + side2 + side3;alert("Your answer is " + cal1 + " " + unit);}function perimCir(){var unit = prompt("Unit of measurement:");var diam = eval(prompt("Diameter of the circle:"));var cal1 = diam * 3.1415926535;alert("The circumference \n(perimeter of the circle)\n is " + cal1 + " " + unit);}//area functionsfunction areaSquare(){var unit = prompt("Unit of measurement:");var side1 = eval(prompt("Length of one side:"));var cal1 = side1 * side1;alert("Your answer is " + cal1 + " square " + unit);}function areaRect(){var unit = prompt("Unit of measurement:");var side1 = eval(prompt("Length:"));var side2 = eval(prompt("Width:"));var cal1 = side1 * side2;alert("Your answer is " + cal1 + " square " + unit);}function areaPara(){var unit = prompt("Unit of measurement:");var side1 = eval(prompt("Base:"));var side2 = eval(prompt("Height:"));var cal1 = side1 * side2;alert("Your answer is " + cal1 + " square " + unit);}function areaTrap(){var unit = prompt("Unit of measurement:");var side1 = eval(prompt("Base one:"));var side2 = eval(prompt("Base two:"));var side3 = eval(prompt("Height:"));var cal1 = side1 + side2;var cal2 = side3 / 2;var cal3 = cal2 * cal1;alert("Your answer is " + cal3 + " square " + unit);}function areaCir(){var unit = prompt("Unit of measurement:");var side1 = eval(prompt("Radius:"));var cal1 = side1 * side1 * 3.1415926535;alert("Your answer is " + cal1 + " square " + unit);}function areaEllip(){var unit = prompt("Unit of measurement:");var side1 = eval(prompt("Radius one:"));var side2 = eval(prompt("Radius two:"));var cal1 = side1 * side2 * 3.1415926535;alert("Your answer is " + cal1 + " square " + unit);}function areaTri(){var unit = prompt("Unit of measurement:");var side1 = eval(prompt("Base:"));var side2 = eval(prompt("Height:"));var cal1 = .5 * side1 * side2;alert("Your answer is " + cal1 + " square " + unit);}//volume functionsfunction volCube(){var unit = prompt("Unit of measurement:");var side1 = eval(prompt("Length of one side:"));var cal1 = side1 * side1 * side1;alert("Your answer is " + cal1 + " cubic " + unit);}function volRectPrism(){var unit = prompt("Unit of measurement:");var side1 = eval(prompt("Length:"));var side2 = eval(prompt("Width:"));var side3 = eval(prompt("Height:"));var cal1 = side1 * side2 * side3;alert("Your answer is " + cal1 + " cubic " + unit);}function volCyl(){var unit = prompt("Unit of measurement:");var side1 = eval(prompt("Radius of the bottom:"));var side2 = eval(prompt("Height of the cylinder:"));var cal1 = side1 * side1 * 3.1415926535 * side2;alert("Your answer is " + cal1 + " cubic " + unit);}function volPyr(){var unit = prompt("Unit of measurement:");var side1 = eval(prompt("Length of one side of the base of the pyramid:"));var side2 = eval(prompt("Height of the pyramid:"));var cal1 = .33333333 * side1 * side2;alert("Your answer is " + cal1 + " cubic " + unit);}function volCone(){var unit = prompt("Unit of measurement:");var side1 = eval(prompt("Radius of the bottom of the cone:"));var side2 = eval(prompt("Height of the cone:"));var cal1 = side1 * side1 * side2 * 3.1415926535 * .33333333;alert("Your answer is " + cal1 + " cubic " + unit);}function volSphere(){var unit = prompt("Unit of measurement:");var side1 = eval(prompt("Radius of the sphere:"));var cal1 = side1 * side1 * side1 * 3.1415926535 * 1.33333333;alert("Your answer is " + cal1 + " cubic " + unit);}//--></script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<font face="arial" color="darkblue"><b>Basic Arithmetic Functions</b><br><input type="button" value="  +  " onclick="add()"><input type="button" value="  -  " onclick="subtract()"><input type="button" value="  *  " onclick="multiply()"><input type="button" value="  /  " onclick="divide()"><br><br><b>Decimal and Fractional Functions</b><br><input type="button" value="  percentages  " onclick="percentage()"><input type="button" value="  change a fraction to a decimal  " onclick="fractToDec()"><br><br><b>Perimeter</b><br><input type="button" value="  square  " onclick="perimSquare()"><input type="button" value="  rectangle  " onclick="perimRect()"><input type="button" value="  triangle  " onclick="perimTri()"><input type="button" value="  circle  " onclick="perimCir()"><br><br><b>Area</b><br><input type="button" value="  square  " onclick="areaSquare()"><input type="button" value="  rectangle  " onclick="areaRect()"><input type="button" value="  triangle  " onclick="areaTri()"><input type="button" value="  circle  " onclick="areaCir()"><input type="button" value="  trapeziod  " onclick="areaPara()"><input type="button" value="  parrallelogram  " onclick="areaTrap()"><input type="button" value="  ellipse  " onclick="areaEllip()"><br><br><b>Volume</b><br><input type="button" value="  cube  " onclick="volCube()"><input type="button" value="  rectangular prism  " onclick="volRectPrism()"><input type="button" value="  cylinder  " onclick="volCyl()"><input type="button" value="  pyramid  " onclick="volPyr()"><input type="button" value="  cone  " onclick="volCone()"><input type="button" value="  sphere  " onclick="volSphere()"><br><br><br><br></font><h6><font face="arial" color="darkblue">Copyright (c) 2001 by David Tinoco</font></h6><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->