Write a program that aims to find how many kilometers a car can travel before the fuel in itstank runs out.The fuel consumption according to the average speed of the car is shown in the below...

Write a program that aims to find how many kilometers a car can travel before the fuel in itstank runs out.The fuel consumption according to the average speed of the car is shown in the below table.Average speed(km/h)Fuel consumption(liters/km)0-50 (50 is included) 0.1050-80 (80 is included) 0.0780-120 (120 is included) 0.05> 120 Average speed x 0.0005For example, a car travelling with various speeds consume fuel in one hour as follows:Average speed(km/h)Hourly fuel consumption(liters)Hourly distance traveled(km)40 km/h (40 km/h) x (0.10 lt/km) x (1 h) = 4.0 lt (40 km/h) x (1 h) = 40 km60 km/h (60 km/h) x (0.07 lt/km) x (1 h) = 4.2 lt (60 km/h) x (1 h) = 60 km150 km/h (150 km/h) x (150 x 0.0005 lt/km) x (1 h) = 11.25 lt (150 km/h) x (1 h) = 150 kmWrite a program that does the following:1- Ask the user for the amount of fuel in the tank. The tank capacity is 45 liters. If theuser enters a value less than or equal to zero or a value greater than 45, the programshould give a warning and stop.2- Ask the user for the average speed of the car at each hour.3- Print the hour in which the car runs out of fuel and the total distance it travels.Make sure you place comments in your program. Place your name, ID, what this programdoes and the date this program was written as comments at the top.You should only use the features and commands you have learnt until this homework wasgiven. You are NOT ALLOWED to use the BREAK, CONTINUE, RETURN commands.



UNIV199 Introduction to Programming with Python Homework #5 Due: November 10, 2021, Wednesday, 23:59. Simple WHILE loops: Road Trip Write a program that aims to find how many kilometers a car can travel before the fuel in its tank runs out. The fuel consumption according to the average speed of the car is shown in the below table. Average speed (km/h) Fuel consumption (liters/km) 0-50 (50 is included) 0.10 50-80 (80 is included) 0.07 80-120 (120 is included) 0.05 > 120 Average speed x 0.0005 For example, a car travelling with various speeds consume fuel in one hour as follows: Average speed (km/h) Hourly fuel consumption (liters) Hourly distance traveled (km) 40 km/h (40 km/h) x (0.10 lt/km) x (1 h) = 4.0 lt (40 km/h) x (1 h) = 40 km 60 km/h (60 km/h) x (0.07 lt/km) x (1 h) = 4.2 lt (60 km/h) x (1 h) = 60 km 150 km/h (150 km/h) x (150 x 0.0005 lt/km) x (1 h) = 11.25 lt (150 km/h) x (1 h) = 150 km Write a program that does the following: 1- Ask the user for the amount of fuel in the tank. The tank capacity is 45 liters. If the user enters a value less than or equal to zero or a value greater than 45, the program should give a warning and stop. 2- Ask the user for the average speed of the car at each hour. 3- Print the hour in which the car runs out of fuel and the total distance it travels. Make sure you place comments in your program. Place your name, ID, what this program does and the date this program was written as comments at the top. You should only use the features and commands you have learnt until this homework was given. You are NOT ALLOWED to use the BREAK, CONTINUE, RETURN commands. Name your py-file as h05yourlastname.py and then upload it to Blackboard Learn at https://ku.blackboard.com. Anyone e-mailing his/her homework will lose points! While doing all your homework assignments, remember that:  You should not work together,  You should not give or take any files,  You should not give or take help other than simple verbal hints. https://ku.blackboard.com/ Your output should look as bellow: How many liters of fuel are there in the tank: 49 The tank cannot hold more than 45 liters of fuel. How many liters of fuel are there in the tank: -2 You need a positive amount of fuel in the tank. How many liters of fuel are there in the tank: 4 What is the average speed of the car in the first hour: 100 During hour 1 the car runs out of fuel. The total distance traveled is 80.0 km. How many liters of fuel are there in the tank: 10 What is the average speed of the car in the first hour: 50 What is the average speed of the car in the next hour: 50 During hour 2 the car runs out of fuel. The total distance traveled is 100.0 km. How many liters of fuel are there in the tank: 10 What is the average speed of the car in the first hour: 120 What is the average speed of the car in the next hour: 120 During hour 2 the car runs out of fuel. The total distance traveled is 200.0 km. How many liters of fuel are there in the tank: 10 What is the average speed of the car in the first hour: 125 What is the average speed of the car in the next hour: 125 During hour 2 the car runs out of fuel. The total distance traveled is 160.0 km. How many liters of fuel are there in the tank: 40 What is the average speed of the car in the first hour: 40 What is the average speed of the car in the next hour: 60 What is the average speed of the car in the next hour: 80 What is the average speed of the car in the next hour: 100 What is the average speed of the car in the next hour: 120 What is the average speed of the car in the next hour: 140 What is the average speed of the car in the next hour: 160 During hour 7 the car runs out of fuel. The total distance traveled is 607.5 km.
Nov 10, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here