Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="pl">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <title>Document</title>
  6. </head>
  7. <body>
  8. <label>
  9. <p>Podaj liczbe 1:</p>
  10. <input type="number" id="numberOne" placeholder="Podaj liczbe 1" />
  11. </label>
  12. <p>Podaj liczbe 2:</p>
  13. <input type="number" id="numberTwo" placeholder="Podaj liczbe 2" />
  14. <br />
  15. </label>
  16. <label>
  17. <input type="submit" value="Licz!" onclick="oblicz()" />
  18. </label>
  19. <p id="wynik"></p>
  20.  
  21. <script>
  22. const date = {
  23. name: "Jakub",
  24. surname: "Wojton",
  25. age: 19,
  26. growth: 202,
  27. write: function(){
  28. alert("Imie: "+this.name+" Nazwisko: " +this.surname+ "Wiek: "+this.age+" Wzrost: "+this.growth);
  29.  
  30. }
  31. }
  32. date.write();
  33.  
  34. function oblicz(){
  35. const a = document.getElementById('numberOne').value;
  36. const b = document.getElementById('numberTwo').value;
  37. const results = document.getElementById('wynik');
  38.  
  39. if(b > 0){
  40. const results2 = (+a + +b)/Math.sqrt(b);
  41. const roundingUp = Math.floor((+a + +b)/(Math.sqrt(b)) *10) /10;
  42. const roundingDown = Math.ceil((+a + +b)/(Math.sqrt(b)) *10) /10;
  43. results.innerHTML = "Wynik to: "+results2+"<br />Zaokraglnie to"+roundingUp+"<br />A tu kolejne "+roundingDown;
  44. }
  45. else{
  46. results.innerHTML = "B nie moze byc mniejsze od 0";
  47. }
  48.  
  49.  
  50. }
  51. </script>
  52. </body>
  53. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement