Challenge: Calculate Shipping Cost
Task
Swipe to start coding
You are building a shipping cost calculator that computes the final shipping price for a product based on its weight and selected delivery option.
- Inside the function
calculateShipping, set the initialshippingPriceto 10% ofproductPrice. - If the product's weight exceeds 25 pounds, add an additional $2.25 to
shippingPrice. - Use a
switchstatement on theoptionparameter:- Case 1 β add $0.3 to
shippingPrice. - Case 2 β add $0.5 to
shippingPrice. - Case 3 β add $1.75 to
shippingPrice. - Default β do nothing.
- Case 1 β add $0.3 to
- Return the value of
shippingPricefrom the function.
Solution
solution.cpp
Everything was clear?
Thanks for your feedback!
SectionΒ 2. ChapterΒ 4
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Suggested prompts:
Can you explain this in simpler terms?
What are the main points I should remember?
Can you give me an example?
Awesome!
Completion rate improved to 7.69
Challenge: Calculate Shipping Cost
Swipe to show menu
Task
Swipe to start coding
You are building a shipping cost calculator that computes the final shipping price for a product based on its weight and selected delivery option.
- Inside the function
calculateShipping, set the initialshippingPriceto 10% ofproductPrice. - If the product's weight exceeds 25 pounds, add an additional $2.25 to
shippingPrice. - Use a
switchstatement on theoptionparameter:- Case 1 β add $0.3 to
shippingPrice. - Case 2 β add $0.5 to
shippingPrice. - Case 3 β add $1.75 to
shippingPrice. - Default β do nothing.
- Case 1 β add $0.3 to
- Return the value of
shippingPricefrom the function.
Solution
solution.cpp
Everything was clear?
Thanks for your feedback!
SectionΒ 2. ChapterΒ 4
single