You are on page 1of 3

CMSC 12: Foundations of Computer Science Exercise 11

Exercise 11: JavaScript 2

INSTRUCTION: Modify your Cake Order Form exercise. Save your files in a zip file,
<surname>_ex11.zip (e.g. trese_ex11.zip). Submit your work on Google classroom and turn it in. Write
your name, section, and code description on the upper part of your document. Do not forget to
document your work.

Modify your Cake Order Form to do the following (add appropriate HTML/JS code):
● Compute the total cost of making the cake. The cake cost is computed as the total of each cake tier
cost.

Each cake tier cost is computed as:

π * radius**2 * 5 * cake_multiplier

where
radius = 2,3,4,5,6 (tier1 has radius 2, tier2 has radius 3, and so on, respectively)
cake_multiplier = the total from the cake flavor, filling, icing, inside cake additions, decorative
additions, and liquid infusion

If you have three (3) tiers,


cake_cost = cake_tier_cost of tier1 + cake_tier_cost of tier2 + cake_tier_cost of tier3

● Add multiplier costs to your wedding cake details.


Example Multiplier Costs:

Cake Flavor Inside Cake Additions


Traditional White 4 Walnut 1
Devil's Food Chocolate 10 Chocolate Chips 1
Red Velvet 6 Pecans 1
Lemon 6 White Chocolate Chips 1

Filling Decorative Additions


Raspberry Jam 1 Walnut 1
Strawberry Jam 1 Chocolate Chips 1
Buttercream 2 Pecans 1
Apricot Jam 2 White Chocolate Chips 1

Icing Liquid Infusion


Buttercream 2 Rum 2
Cream Cheese 2 Amaretto 5
Mocha Espresso 3 Kaluha 2
None 0

● Add an option for store pickup or delivery. Delivery Address, preferred delivery date, and preferred
delivery time should be disabled when store pickup is selected (it should be selected by default).
Enable these when Delivery is selected. These should be disabled once Store Pickup is selected
again. Add a delivery fee.
● Add additional form validation:
Make sure that the preferred delivery date is in the future. Show a message if it's not (remove the
message upon selecting a valid date).
Preferred delivery time should only be between 6am to 6pm. Show a message if it's not (remove
the message upon selecting a valid time).

● Show a summary of the order after a successful submit (using an alert). Add the following code to
prevent the page from reloading after a submit (make sure to put it at the end of the <body>, in
this example, "form" is the id of the form).
● Tips:
If you need to convert a value to a number, you can use parseInt().
You can use Date.parse(<Date>) to convert the Date into a number.
See what the onChange() event does!

You might also like