Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Titular Title</title>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- </head>
- <body>
- <script type="text/javascript">
- operation=-1;
- while (operation != 0)
- {
- var operation=prompt("Which operation do you wish to do?\n0: End Program\n1: Addition\n2: Subtraction\n3: Multiplication\n4: Division\n5: Square Root","");
- //addition, subtraction, multiplication, or division
- if (operation>0 && operation<5)
- {
- var num1=parseInt(prompt("Enter the first number.",""));
- var num2=parseInt(prompt("Enter the second number.",""));
- if (operation==1) alert("The sum is "+(num1+num2));
- if (operation==2) alert("The difference is "+(num1-num2));
- if (operation==3) alert("The product is "+(num1*num2));
- if (operation==4) alert("The quotient is "+(num1/num2));
- }
- //square root
- else if (operation==5)
- {
- var num1=parseInt(prompt("Enter the number you want to take the square root of.",""));
- alert("The square root is "+Math.sqrt(num1));
- }
- else
- {
- if (operation!=0) alert("That wasn't one of the options");
- }
- }
- </script>
- <div>Titular Content</div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment