Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var math = {
- 1 : function() {
- var a = prompt("A: "), b = prompt("B: "), c = prompt("C: ")
- alert (
- a == "?" && "A = " + Math.sqrt(Math.pow(c, 2) - Math.pow(b, 2)) ||
- b == "?" && "B = " + Math.sqrt(Math.pow(c, 2) - Math.pow(a, 2)) ||
- c == "?" && "C = " + Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2)) ||
- "error, invalid parameters"
- )
- },
- 2 : function() {
- var r = prompt("R: "), t = prompt("T: "), d = prompt("D: ")
- alert (
- r == "?" && "R = " + d / t ||
- t == "?" && "T = " + d / r ||
- d == "?" && "D = " + r * t ||
- "error, invalid parameters"
- )
- }
- }
- while (true) {
- math[parseInt(prompt(
- "1) Pythagorean Theorem (a² + b² = c²)\n" +
- "2) Distance (rt = d)\n"
- ))]()
- }
Advertisement
Add Comment
Please, Sign In to add comment