A car starts from rest and moves with a constant acceleration along a straight horizontal road for a given time. Write a PHP script that prompts the user to enter the acceleration and the time the car traveled, and then calculates and displays the distance traveled. The required formula is


  • S is the distance the car traveled, in meters (m)
  • uo is the initial velocity (speed) of the car, in meters per second (m/sec)
  • t is the time the car traveled, in seconds (sec)
  • a is the acceleration, in meters per second2 (m/sec2)

Since the car starts from rest, the initial velocity (speed) u0 is zero. Thus, the formula becomes

and the program is





Visual Basic


Leave a Reply

Your email address will not be published. Required fields are marked *

This article is taken from a book of mine. If you enjoyed it, please visit my author's page inand check out all of my books!