CyberStars

Recap: Road Trip Calculator

Time to combine what you've learned so far! No new theory, just a challenge that uses print, variables, and comments


Mission: The Magnetic Tape Reel Courier

A van transports magnetic tape reels between two computing centers. The shift operator has to calculate how much fuel the trip consumes and how much it costs, before approving the shipment.

Write a program that, inside main

  • declares an int named distance_km (any whole number you like)
  • declares a double named consumption_per_km (any value you like)
  • declares a double named price_per_liter (any value you like)
  • calculates the total fuel needed (distance_km * consumption_per_km); put a comment above this calculation
  • calculates the total cost (total fuel * price_per_liter); put a comment above this calculation
  • prints the three values, each on its own line, rounded to 2 decimals where relevant

Example

For distance_km = 450, consumption_per_km = 0.07 and price_per_liter = 1.75, your program would print something like

Distance: 450 km
Fuel: 31.50 liters
Cost: 55.13 EUR