CJCoding With Joseph
15free / daySign inCreate account

Road Trip Summary

Write a program with no input that prints a road trip summary. Declare, with type hints, four floats: the distance 412.0 km, the fuel used 31.5 litres, the price per litre 1.459 and the driving time 4.5 hours. Compute three more typed floats: the fuel cost (litres times price), the average speed (distance divided by hours) and the consumption in litres per 100 km (litres divided by distance, times 100). Print the title Road Trip Summary followed by a blank line (use end= with two newlines), then: the label Distance with a colon, the distance as stored and the unit km, passed as three values to one print call; Average speed with the speed to one decimal using :0.1f and the unit km/h; Fuel used with the litres to one decimal, the letter L, the word at, the price to two decimals and the words per litre; Fuel cost with the cost to two decimals using :0.2f; and Consumption with the consumption to two decimals and the unit L/100km. Each label is followed by a colon and a space. Input: none.

Expected Output:

Road Trip Summary

Distance: 412.0 km
Average speed: 91.6 km/h
Fuel used: 31.5 L at 1.46 per litre
Fuel cost: 45.96
Consumption: 7.65 L/100km

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
PrintingVariables
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.