Advertisement
kirya_shkolnik

Матвей JS - 6

May 22nd, 2021
1,169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. document.write("Вычисление стоимости покупки с учетом скидки");
  2. let purchase = +prompt("Стоимость покупки");
  3. document.write("<br> Сумма без скидки: " + purchase);
  4. let discount = 0;
  5. let discountFrom500 = 0.03;
  6. let discountFrom1000 = 0.05;
  7. let summary = purchase;
  8. if(purchase > 1000){
  9.     discount = discountFrom1000;
  10.  
  11. }
  12. else if(purchase > 500){
  13.     discount = discountFrom500;
  14. }
  15. else{
  16.     discount = 0;
  17.  
  18. }
  19. summary*=(1-discount);
  20.  
  21.  
  22.  
  23. document.write("<br> Вам предоставляется скидка : " + discount * 100 + "%");
  24. document.write("<br> Итоговая сумма: " + summary);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement