Section 2. Chapter 11
single
Challenge: Coffee Bag Weight Conversion
Swipe to show menu
Task
Swipe to start coding
A coffee shop tracks the weight of coffee bags for delivery.
- Store the original weight (
750) as anintconstant namedBAG_WEIGHT. - Use implicit casting to convert it to a
doublevariable namedweight. - Update
weightto760.5to reflect a packaging change. - Use explicit casting to convert
weightback to anintfor reporting. - Print the updated
doubleweight and the finalintreported weight. Output should be as follows:
Updated bag weight (double):
760.5
Final reported weight (int):
760
Solution
Everything was clear?
Thanks for your feedback!
Section 2. Chapter 11
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat