ForeverDev

Untitled

Oct 9th, 2014
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var math = {
  2.     1 : function() {
  3.         var a = prompt("A: "), b = prompt("B: "), c = prompt("C: ")
  4.         alert (
  5.             a == "?" && "A = " + Math.sqrt(Math.pow(c, 2) - Math.pow(b, 2)) ||         
  6.             b == "?" && "B = " + Math.sqrt(Math.pow(c, 2) - Math.pow(a, 2)) ||
  7.             c == "?" && "C = " + Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2)) ||
  8.             "error, invalid parameters"
  9.         )
  10.     },
  11.     2 : function() {
  12.         var r = prompt("R: "), t = prompt("T: "), d = prompt("D: ")
  13.         alert (
  14.             r == "?" && "R = " + d / t ||
  15.             t == "?" && "T = " + d / r ||
  16.             d == "?" && "D = " + r * t ||
  17.             "error, invalid parameters"
  18.         )
  19.     }
  20. }
  21.  
  22. while (true) {
  23.     math[parseInt(prompt(
  24.         "1) Pythagorean Theorem (a² + b² = c²)\n" +
  25.         "2) Distance (rt = d)\n"
  26.     ))]()
  27. }
Advertisement
Add Comment
Please, Sign In to add comment