2014-11-12 21:41:38 -05:00
<!DOCTYPE html>
< html lang = "en" >
< head >
2014-11-13 07:50:35 -05:00
< meta charset = "UTF-8" >
2014-11-12 21:41:38 -05:00
< link href = 'http://fonts.googleapis.com/css?family=Roboto+Slab' rel = 'stylesheet' type = 'text/css' >
< link href = "css/style.css" rel = "stylesheet" >
< script src = "js/jquery.js" > < / script >
< script src = "js/two.min.js" > < / script >
< script src = "js/randomColor.js" > < / script >
< style type = "text/css" >
2014-11-13 07:50:35 -05:00
.eq, #result, p {
2014-11-12 21:41:38 -05:00
display: inline;
margin:0px;
padding:0px;
}
< / style >
< script type = "text/javascript" >
function Calculate(){
var form = document.getElementById("calculator");
var output = form.elements["c"];
var a = parseInt(form.elements["a"].value);
var b = parseInt(form.elements["b"].value);
var op = parseInt(form.elements["selector"].value);
switch(op){
case 0:
output.value = a * b;
break;
case 1:
output.value = a / b;
break;
case 2:
output.value = a + b;
break;
case 3:
output.value = a - b;
break;
case 4:
output.value = Math.log(a);
break;
case 5:
output.value = Math.pow(a, b);
break;
case 6:
output.value = Math.tan(a);
break;
case 7:
output.value = Math.cos(a);
break;
case 8:
output.value = Math.sin(a);
break;
case 9:
output.value = Math.abs(a);
break;
case 10:
output.value = Math.exp(a);
break;
default:
break;
}
}
< / script >
2014-11-12 22:00:52 -05:00
< title > RPN Calculator< / title >
2014-11-12 21:41:38 -05:00
< / head >
< body >
< canvas id = "screen" >
< / canvas >
2014-11-12 22:00:52 -05:00
< div id = "front" >
2014-11-12 21:41:38 -05:00
< h2 > Reverse Polish Notation Calculator< / h2 >
< p > * For Single number operations, only use first field< / p >
2014-11-13 07:50:35 -05:00
< form id = "calculator" oninput = "Calculate()" >
2014-11-12 21:41:38 -05:00
< input name = "a" type = "number" value = "0" / >
< input name = "b" type = "number" value = "0" / >
< select name = "selector" onchange = "Calculate()" >
< option value = "-1" > Select an Operation< / option >
< option value = "0" > *< / option >
< option value = "1" > /< / option >
< option value = "2" > +< / option >
< option value = "3" > -< / option >
< option value = "4" > log< / option >
< option value = "5" > ^< / option >
< option value = "6" > tan< / option >
< option value = "7" > cos< / option >
< option value = "8" > sin< / option >
< option value = "9" > abs< / option >
< option value = "10" > e^x< / option >
< / select >
< div class = "eq" > = < / div >
< output id = "result" name = "c" for = "x y" > 0< / output >
< / form >
< h4 > © Paul Walko 2014< / h4 >
2014-11-13 07:50:35 -05:00
< a href = "http://www.w3.org/html/logo/" > < img src = "http://www.w3.org/html/logo/badge/html5-badge-h-css3-semantics.png" width = "165" height = "64" alt = "HTML5 Powered with CSS3 / Styling, and Semantics" title = "HTML5 Powered with CSS3 / Styling, and Semantics" >
< / a >
2014-11-12 21:41:38 -05:00
< / div >
< script type = "text/javascript" src = "js/background2.js" > < / script >
< / body >
2014-11-12 22:00:52 -05:00
< / html >