Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Coffee Bag Weight Conversion | Variables and Data Types
Introduction to Java
Section 2. Chapter 11
single

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.

  1. Store the original weight (750) as an int constant named BAG_WEIGHT.
  2. Use implicit casting to convert it to a double variable named weight.
  3. Update weight to 760.5 to reflect a packaging change.
  4. Use explicit casting to convert weight back to an int for reporting.
  5. Print the updated double weight and the final int reported weight. Output should be as follows:
Updated bag weight (double):
760.5
Final reported weight (int):
760

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 2. Chapter 11
single

single

Ask AI

expand

Ask AI

ChatGPT

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

some-alt