forked from ax1x0/Bookmarklets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalculator
1 lines (1 loc) · 2.97 KB
/
Calculator
1
javascript: var versionCalc = prompt('1). Basic Calculator\n2). Equations');switch (versionCalc) { case '1': var operatorType = parseInt(prompt('1). Addition\n2). Subtraction\n3). Multiplication\n4). Division')); switch (operatorType) { case 1: var num1 = parseInt(prompt('First Number:')); var num2 = parseInt(prompt('Second Number:')); result = num1 + num2; break; case 2: var num1 = parseInt(prompt('First Number:')); var num2 = parseInt(prompt('Second Number:')); result = num1 - num2; break; case 3: var num1 = parseInt(prompt('First Number:')); var num2 = parseInt(prompt('Second Number:')); result = num1 * num2; break; case 4: var num1 = parseInt(prompt('First Number:')); var num2 = parseInt(prompt('Second Number:')); result = num1 / num2; break; default: alert('That is not a valid input. Input the number of the operation you are trying to run'); break; }; break; case '2': var equationType = parseInt(prompt('1). Slope\n2). Area of a circle\n3). Area of a square/rectangle\n4). Area of a triangle\n5). Volume of a cube\n6). Distance\n7). Time\n8). Speed')); switch (equationType) { case 1: m = parseInt(prompt("What is the rise/run? (M)")); x = parseInt(prompt("What is the distance of the line from the x-axis? (X)")); b = parseInt(prompt("What is the Y-Intercept? (B)")); result = (m * x) + b; break; case 2: r = parseInt(prompt(%27What is the radius of the circle? (R)%27)); r2 = r * r; result = r2 * 3.14; break; case 3: l = parseInt(prompt(%27What is the length?%27)); w = parseInt(prompt(%27What is the width?%27)); result = l * w; break; case 4: b = parseInt(prompt("What is the base of the triangle?")); h = parseInt(prompt("what is the height of the triangle?")); result = (b * h) / 2; break; case 5: l = parseInt(prompt(%27What is the length?%27)); w = parseInt(prompt(%27What is the width?%27)); h = parseInt(prompt(%27What is the height?%27)); result = l * w * h; break; case 6: s = parseInt(prompt(%27What is the speed?%27)); t = parseInt(prompt(%27What is the time?%27)); result = s * t; break; case 7: s = parseInt(prompt(%27What is the speed?%27)); d = parseInt(prompt(%27What is the distance?%27)); result = d / s; break; case 8: s = parseInt(prompt(%27What is the time?%27)); d = parseInt(prompt(%27What is the distance?%27)); result = d / t; break; default: alert(%27That is not a valid input. Input the number of the operation you are trying to run%27); break; }; break; default: alert(%27That is not a valid input. Input the number of the operation you are trying to run%27); };alert(%27Your answer is %27 + result);