<!DOCTYPE html> <html> <head> <title>Calculadora</title> <meta charset="utf-16"> <style type="text/css"> p { color: White; } h1 {color:rgb(255,255,255);} button {color:rgb(255,0,0);} button {background:rgb(255,255,0);} body {background:rgb(127,159,255);} </style> <script type="text/javascript"> var num, acc = "0", op = ""; function mas() { acc = num.value; op = "+"; } function menos() { acc = num.value; op = "-"; } function multiplicar() {acc = num.value; op = "*"; } function dividir() { acc = num.value; op = "/"; } function cuadrado() { acc = num.value = num.value * num.value; } function inverso () { acc = num.value = 1/num.value;} function raiz () { acc = num.value = Math.sqrt(acc);} function calcular() { if (op === "+") {num.value = (+acc + +num.value)} if (op === "-") {num.value = (+acc - +num.value)} if (op === "*") {num.value = (+acc * +num.value)} if (op === "/") {num.value = (+acc / +num.value)} } function inic () {num = document.getElementById("num");} function vaciar () {num.value = "";} </script> </head> <body> <h1> Buenos días, bienvenido a la calculadora de": <p> "Patricio Cerda"</h1> </body> <h1 id="h1"></h1> <body onLoad="inic()"> <p> N&uacute;mero:</p><p> <input type="text" size="12" id="num" onClick="vaciar()"><p> <button onClick="mas()">+ </button> <button onClick="menos()">- </button> <button onClick="multiplicar()">* </button> <button onClick="dividir()">/</button> <p> <button onClick="cuadrado()">x<sup>2</sup> </button> <button onclick="inverso()"> 1/x </button> <button onclick="raiz"> V<sup>/2</sup></button> <p> <button onClick="vaciar()">C</button> <button onClick="calcular()">=</button> </p> </body> </html>