Advertisement
pan7nikt

egzamin27_oblicz.js

Sep 23rd, 2022
759
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function oblicz()
  2. {
  3.     var canproceed = true;
  4.  
  5.     var liczba = Math.round(document.getElementById("liczba").value);
  6.     var upust = document.getElementById("upust").checked;
  7.  
  8.     var polewynik = document.getElementById("wynik");
  9.  
  10.     if(liczba <= 0){polewynik.innerHTML = "Liczba musi być większa niż 0!"; canproceed = false;}
  11.  
  12.     if(canproceed)
  13.     {
  14.         var wynik = 0;
  15.  
  16.         if(liczba <= 50)
  17.         {
  18.             if(upust)
  19.             {
  20.                 wynik = liczba * 1.8;
  21.             }
  22.             else
  23.             {
  24.                 wynik = liczba * 2;
  25.             }
  26.         }
  27.         else
  28.         {
  29.             if(upust)
  30.             {
  31.                 wynik = liczba * 0.8;
  32.             }
  33.             else
  34.             {
  35.                 wynik = liczba * 1;
  36.             }
  37.         }
  38.  
  39.         polewynik.innerHTML = "Koszt ogłoszeń: " + wynik + " PLN";
  40.     }
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement