Advertisement
476179

6.2Act2

Nov 1st, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>6</title>
  6. </head>
  7.  
  8. <body>
  9. <script>
  10. var eq1, eq2, eq3, eq4;
  11. //alert("This program will process 2 numbers using addition, subtraction, multiplication or division.");
  12.  
  13. // var n1 =parsefloat(prompt("enter the first number"));
  14. var n2 =parsefloat(prompt("enter the second number"));
  15. var eqn = prompt("choose one operation from the following list: \nA โ€“ Addition \nS โ€“ Subtraction\nM โ€“ Multiplication\nD - Division");
  16.  
  17. if (eqn = "A" )
  18. {
  19. eq1 = n1 + n2;
  20. alert(n1 + " + "+n2+" = "+eq1);
  21. }
  22. else if (eqn = "S" )
  23. {
  24. eq2 = n1 - n2;
  25. alert(n1 + " - "+n2+" = "+eq2);
  26. }
  27. else if (eqn = "M" )
  28. {
  29. eq3 = n1 * n2;
  30. alert(n1 + " * "+n2+" = "+eq3);
  31. }
  32. else if (eqn = "D" )
  33. {
  34. eq4 = n1 / n2;
  35. alert(n1 + " รท "+n2+" = "+eq4);
  36. }
  37. else
  38. {
  39. alert(" please try again, remember when selscting a computation method to print the shortend variable as shown (A,S,M or D) ");
  40. }
  41. </script>
  42. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement