Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Calculate Shipping Cost | Section
C++ Conditional Statements
SectionΒ 1. ChapterΒ 10
single

single

bookChallenge: 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.

  1. Inside the function calculateShipping, set the initial shippingPrice to 10% of productPrice.
  2. If the product's weight exceeds 25 pounds, add an additional $2.25 to shippingPrice.
  3. Use a switch statement on the option parameter:
    • Case 1 β†’ add $0.3 to shippingPrice.
    • Case 2 β†’ add $0.5 to shippingPrice.
    • Case 3 β†’ add $1.75 to shippingPrice.
    • Default β†’ do nothing.
  4. Return the value of shippingPrice from the function.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 10
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

some-alt