Advertisement
Guest User

Untitled

a guest
Feb 24th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2.  
  3. <html>
  4.    
  5.     <head>
  6.             <title>Assignment 5: Basic JS</title>
  7.     </head>
  8.  
  9.     <body>
  10.  
  11.         <!-- COMPLETE BELOW     -->
  12.        
  13.         <!--
  14.             NetID:hmc86
  15.             Section:16
  16.             TA:Ramina Nayak
  17.         -->
  18.  
  19.         <script>
  20.            
  21.             /* 1. Create variables */
  22.             var item = prompt("Which item would you like? (TV/VGC/Laptop)");
  23.             var tagPrice;
  24.             var quantity = prompt("How many?");
  25.             var shippingMethod = prompt("Which shipping method would you prefer? (A- one day, B - two day, C - someday)");
  26.             var tax = prompt("Do you pay a state tax? (yes/no)");
  27.             var stateTax=1;
  28.             var totalPrice=0;
  29.            
  30.  
  31.  
  32.  
  33.            
  34.             /* 2. Determine item price */
  35.             if (item == "TV")
  36.                 tagPrice = 1200;
  37.             else if (item == "VGC")
  38.                 tagPrice = 399;
  39.             else if (item == "Laptop")
  40.                 tagPrice = 1799;
  41.             else {
  42.                 window.alert("We do not carry that item, try again!");
  43.                 location.reload();}
  44.        
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.             /* 3. Determine quantity */
  53.             if (quantity < 1)
  54.                 window.alert("Nothing to do here, bye!");
  55.                 location.reload();
  56.             else if (quantity == 1)
  57.                 tagPrice = 1;
  58.             else if (quantity == 2)
  59.                 tagPrice = tagPrice * 0.98;
  60.             else if (quantity == 3)
  61.                 tagPrice = tagPrice * 0.9;
  62.             else if (quantity >= 4)
  63.                 tagPrice = tagPrice *0.8;
  64.          
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.             /* 4. Select Shipping Method */
  73.             if (shippingMethod == A)
  74.                 tagPrice = tagPrice + 29;
  75.             else if (shippingMethod == B)
  76.                 tagPrice = tagPrice +14;
  77.             else if (shippingMethod == C)
  78.                 tagPrice = tagPrice;
  79.             else
  80.                 window.alert("That method is NOT available, try again!");
  81.                 location.reload();
  82.            
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.             /* Determine tax */
  91.             if (tax == yes)
  92.                 stateTax = prompt("What is your tax as a decimal value?");
  93.             else if (tax == no)
  94.                 stateTax = 1
  95.            
  96.            
  97.  
  98.  
  99.            
  100.             /* Compute Total */
  101.             totalPrice += (tagPrice * quantity * stateTax);
  102.             window.alert(totalPrice);
  103.            
  104.  
  105.  
  106.         </script>
  107.  
  108.         <!-- END OF ASSIGNMENT  -->
  109.        
  110.     </body>
  111.  
  112. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement