One formula for computing the distance an object travels is
One formula for computing the distance an object travels is: S = (V_i + V_t) t/2 where: s = distance traveled v_i = initial velocity of the object v_f = final velocity of the object t = amount of time the object traveled t = amount of time the object traveled Write an algorithm for computing the distance traveled for some object. The initial velocity, the final velocity, and the amount of me the object traveled are required inputs for this problem. The output is the distance traveled. Use plain English statements (no programming instructions required), and number your steps. For our purposes you may ignore units. We would like for the distance traveled to be a floating point value. Discuss any issues involved in making sure that a C program will compute the correct value using the formula above.
Solution
Algorithm:
1. Input initial velocity
v1 <- input
2. Input final velocity
v1 <- input
3. Input amount of time object has traveled
t <- input
4.
distance = (v1+v2)*t/2
5. print distance
When all parameters of division are integer value then rea=sult also will be integer value.
In this case we can loose floting point value.
Wx- 5/2 = 2 , so to get correct result, 5/2.0 = 2.5
So, distance = (v1+v2)*t/2.0
