Javascript Assignment 1


SUBMITTED BY: Guest

DATE: Oct. 25, 2013, 3:56 p.m.

FORMAT: JavaScript

SIZE: 2.5 kB

HITS: 986

  1. <html>
  2. <head>
  3. <title> Javascript Assignment 1: [Ankur Chadha]</title>
  4. </head>
  5. <body>
  6. <!--Ankur Chadha, Nikolay, Javascript Assignment 1, Due: 10/18/13-->
  7. <h1> Welcome to My Online Store!</h1>
  8. <h2> Disclaimer! We do not ship more than 20 units of plain bagels at a time due to low supply!</h2>
  9. <table border="1">
  10. <tr>
  11. <th>Product</th>
  12. <th>Price</th>
  13. </tr>
  14. <tr>
  15. <td>Plain Bagel</td>
  16. <td>$1.00</td>
  17. </tr>
  18. <tr>
  19. <td>Poppyseed Bagel</td>
  20. <td>$1.25</td>
  21. </tr>
  22. <tr>
  23. <td>Philadelphia Cream Cheese Tub</td>
  24. <td>$2.25</td>
  25. </table>
  26. <script type="text/javascript">
  27. var Name = prompt ("Please Enter Your Name");
  28. var Plain = 1*prompt ("Enter the Quantity of Plain Bagels you would like");
  29. if (Plain > 20) {
  30. alert("You have entered an amount to great to ship. Please refresh the page and try again!");
  31. }
  32. else {
  33. var Poppyseed = 1 * prompt("Enter the Quantity of Poppyseed Bagels you would like");
  34. var Creamcheese = 1 * prompt("Enter the Quantity of Tubs of Cream Cheese you would like");
  35. var BillingAddress = prompt("Please enter the address of where you would like your delicious bagels shipped to in the following format: Street Address, City, State ZIP");
  36. var subtotal = (Plain * 1) + (Poppyseed * 1.25) + (Creamcheese * 2.25);
  37. var totalitem = Plain + Poppyseed + Creamcheese;
  38. if ((Plain > 5 || Poppyseed > 5 || Creamcheese > 5) && (totalitem > 10)) {
  39. subtotal = subtotal * .90 - subtotal * .90 * .05;
  40. }
  41. else if ((Plain <= 5 || Poppyseed <= 5 || Creamcheese <= 5) && (totalitem > 10)) {
  42. subtotal = subtotal * .95;
  43. }
  44. else if ((Plain > 5 || Poppyseed > 5 || Creamcheese > 5) && (totalitem <= 10)) {
  45. subtotal = subtotal * .90;
  46. }
  47. else if ((Plain <= 5 || Poppyseed <= 5 || Creamcheese <= 5) && (totalitem <= 10)) {
  48. subtotal = (Plain * 1) + (Poppyseed * 1.25) + (Creamcheese * 2.25);
  49. }
  50. var taxRate = .07;
  51. var Total = subtotal + (subtotal * taxRate);
  52. document.write("CONFIRMATION: Thank you, " + Name, ". Your order totaling: $" + Total, " will be delievered to " + BillingAddress, " within 24 hours. Thank you for shopping with us.");
  53. }
  54. </script>
  55. </body>
  56. </html>

comments powered by Disqus