Fredin

Untitled

Jan 30th, 2012
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. document.writeln("Exercise 3.1");
  2. document.writeln("<hr>");
  3.  
  4. var tal1;
  5. var tal2;
  6.  
  7. function numberInput()
  8. {
  9.     tal1 = prompt("Wilkommen till haxxet", "Skriv tal 1");
  10.     tal2 = prompt("Wilkommen till haxxet", "Skriv tal 2");
  11.  
  12.     addition();
  13.     multiply();
  14.     subtract();
  15.     division();
  16. }
  17.  
  18. function addition()
  19. {
  20.     var additionResult;
  21.     additionResult = parseInt(tal1) + parseInt(tal2);
  22.     document.writeln(tal1 + " + " + tal2 + " = " + additionResult);
  23. }
  24.  
  25. function multiply()
  26. {
  27.     var multipliedResult;
  28.     multipliedResult = parseInt(tal1) * parseInt(tal2);
  29.     document.writeln(tal1 + " * " + tal2 + " = " + multipliedResult);
  30. }
  31.  
  32. function subtract()
  33. {
  34.     var subtractedResult;
  35.     subtractedResult = parseInt(tal1) - parseInt(tal2);
  36.     document.writeln(tal1 + " - " + tal2 + " = " + subtractedResult);  
  37. }
  38.  
  39. function division()
  40. {
  41.     var dividedResult;
  42.     dividedResult = parseInt(tal1) / parseInt(tal2);
  43.     document.writeln(tal1 + " / " + tal2 + " = " + dividedResult); 
  44. }
Advertisement
Add Comment
Please, Sign In to add comment