Advertisement
Guest User

Untitled

a guest
May 20th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. <script type="text/javascript">
  2. var EmployeeDiscount, Over800Discount, ContractorDiscount, SalesTax;
  3. var OrderPrice, Age, Occupation, Subtotal, DiscountRate;
  4. var TaxRate, DiscountFactor, FinalCost;
  5.  
  6.  
  7. var EmployeeDiscount = 0.1
  8. var Over800Discount = 0.05
  9. var ContractorDiscount = 0.2
  10. var SalesTax = 0.08
  11.  
  12. var OrderPrice = prompt("What is the price of your order?", "1000");
  13. var Age = prompt("What is your age?", "21");
  14. var Occupation = prompt("Are you an Employee, Contractor, or neither?", "neither");
  15.  
  16. if (OrderPrice > 800)
  17. {
  18. DiscountRate = Over800Discount
  19. }
  20. else
  21. {
  22. DiscountRate = 0
  23. }
  24.  
  25. if (Occupation == "employee")
  26. {
  27. DiscountRate = EmployeeDiscount
  28. }
  29. else
  30. {
  31. if (Occupation == "contractor")
  32. {
  33. DiscountRate = ContractorDiscount
  34. }
  35. else
  36. {
  37. DiscountRate = 0
  38. }
  39. }
  40.  
  41. if (Age > 90)
  42. {
  43. TaxRate = 0
  44. }
  45. else
  46. {
  47. TaxRate = 0.08
  48. }
  49.  
  50. DiscountFactor = OrderPrice * DiscountRate
  51. Subtotal = OrderPrice - DiscountFactor
  52. TaxFactor = Subtotal * TaxRate
  53. FinalCost = Subtotal + TaxFactor
  54.  
  55. document.write("Your order price was" +OrderPrice);
  56. document.write("<br> Your Discounts were" +DiscountFactor);
  57. document.write("<br> Your Subtotal was" +Subtotal);
  58. document.write("<br> Your Taxes were" +TaxFactor);
  59. document.write("<br> Your Final Cost is" +FinalCost);
  60.  
  61.  
  62. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement