willyb321

allcalc

Mar 23rd, 2016
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <title>Titular Title</title>
  5.         <meta charset="UTF-8">
  6.         <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.     </head>
  8.     <body>
  9.         <script type="text/javascript">
  10. operation=-1;
  11. while (operation != 0)
  12. {
  13.    var operation=prompt("Which operation do you wish to do?\n0: End Program\n1: Addition\n2: Subtraction\n3: Multiplication\n4: Division\n5: Square Root","");
  14.   //addition, subtraction, multiplication, or division
  15.   if (operation>0 && operation<5)
  16.   {
  17.   var num1=parseInt(prompt("Enter the first number.",""));
  18.   var num2=parseInt(prompt("Enter the second number.",""));
  19.   if (operation==1) alert("The sum is "+(num1+num2));
  20.   if (operation==2) alert("The difference is "+(num1-num2));
  21.   if (operation==3) alert("The product is "+(num1*num2));
  22.   if (operation==4) alert("The quotient is "+(num1/num2));
  23.   }
  24.   //square root
  25.   else if (operation==5)
  26.   {
  27.   var num1=parseInt(prompt("Enter the number you want to take the square root of.",""));
  28.   alert("The square root is "+Math.sqrt(num1));
  29.   }
  30.   else
  31.   {
  32.   if (operation!=0) alert("That wasn't one of the options");
  33.   }
  34. }
  35. </script>
  36.         <div>Titular Content</div>
  37.     </body>
  38. </html>
Advertisement
Add Comment
Please, Sign In to add comment