Ask Question
15 May, 22:32

Write a program that asks the user for the speed of a vehicle (in miles per hour) and how many hours it has traveled. It should then use a loop to display the total distance traveled at the end of each hour of that time period

+1
Answers (1)
  1. 16 May, 02:01
    0
    speed = float (input ("Enter the speed: "))

    hours = int (input ("Enter the hours: "))

    distance = 0

    for i in range (hours):

    distance + = speed * 1

    print ("The distance after " + str (i+1) + ". hour (s) : " + str (distance))

    Explanation:

    *The code is in Python.

    Ask the user to enter the speed and the hours

    Initialize the distance as 0

    Create a for loop that iterates hours times. Inside the loop, calculate the cumulative distance traveled at the end of each hour and print it (Note that the distance = speed x hour)
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a program that asks the user for the speed of a vehicle (in miles per hour) and how many hours it has traveled. It should then use a ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers