Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Assignment 5: Basic JS</title>
- </head>
- <body>
- <!-- COMPLETE BELOW -->
- <!--
- NetID:hmc86
- Section:16
- TA:Ramina Nayak
- -->
- <script>
- /* 1. Create variables */
- var item = prompt("Which item would you like? (TV/VGC/Laptop)");
- var tagPrice;
- var quantity = prompt("How many?");
- var shippingMethod = prompt("Which shipping method would you prefer? (A- one day, B - two day, C - someday)");
- var tax = prompt("Do you pay a state tax? (yes/no)");
- var stateTax=1;
- var totalPrice=0;
- /* 2. Determine item price */
- if (item == "TV")
- tagPrice = 1200;
- else if (item == "VGC")
- tagPrice = 399;
- else if (item == "Laptop")
- tagPrice = 1799;
- else {
- window.alert("We do not carry that item, try again!");
- location.reload();}
- /* 3. Determine quantity */
- if (quantity < 1)
- window.alert("Nothing to do here, bye!");
- location.reload();
- else if (quantity == 1)
- tagPrice = 1;
- else if (quantity == 2)
- tagPrice = tagPrice * 0.98;
- else if (quantity == 3)
- tagPrice = tagPrice * 0.9;
- else if (quantity >= 4)
- tagPrice = tagPrice *0.8;
- /* 4. Select Shipping Method */
- if (shippingMethod == A)
- tagPrice = tagPrice + 29;
- else if (shippingMethod == B)
- tagPrice = tagPrice +14;
- else if (shippingMethod == C)
- tagPrice = tagPrice;
- else
- window.alert("That method is NOT available, try again!");
- location.reload();
- /* Determine tax */
- if (tax == yes)
- stateTax = prompt("What is your tax as a decimal value?");
- else if (tax == no)
- stateTax = 1
- /* Compute Total */
- totalPrice += (tagPrice * quantity * stateTax);
- window.alert(totalPrice);
- </script>
- <!-- END OF ASSIGNMENT -->
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement