Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- var EmployeeDiscount, Over800Discount, ContractorDiscount, SalesTax;
- var OrderPrice, Age, Occupation, Subtotal, DiscountRate;
- var TaxRate, DiscountFactor, FinalCost;
- var EmployeeDiscount = 0.1
- var Over800Discount = 0.05
- var ContractorDiscount = 0.2
- var SalesTax = 0.08
- var OrderPrice = prompt("What is the price of your order?", "1000");
- var Age = prompt("What is your age?", "21");
- var Occupation = prompt("Are you an Employee, Contractor, or neither?", "neither");
- if (OrderPrice > 800)
- {
- DiscountRate = Over800Discount
- }
- else
- {
- DiscountRate = 0
- }
- if (Occupation == "employee")
- {
- DiscountRate = EmployeeDiscount
- }
- else
- {
- if (Occupation == "contractor")
- {
- DiscountRate = ContractorDiscount
- }
- else
- {
- DiscountRate = 0
- }
- }
- if (Age > 90)
- {
- TaxRate = 0
- }
- else
- {
- TaxRate = 0.08
- }
- DiscountFactor = OrderPrice * DiscountRate
- Subtotal = OrderPrice - DiscountFactor
- TaxFactor = Subtotal * TaxRate
- FinalCost = Subtotal + TaxFactor
- document.write("Your order price was" +OrderPrice);
- document.write("<br> Your Discounts were" +DiscountFactor);
- document.write("<br> Your Subtotal was" +Subtotal);
- document.write("<br> Your Taxes were" +TaxFactor);
- document.write("<br> Your Final Cost is" +FinalCost);
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement