hello, in the following C-program I would like to input ANY time interval (ti) such as 0.3 between 0 to 1 second and get the proper calculated output. The problem I have is that any input I enter I get both results (0 to 1.00 & 0 to 8.00 no matter the value of time intervals. I need it to be one or the other and on top of that any number I input (ti) will give same results between 0-8, maybe a boundary needs to be set
thanks
so far, this is where I am at :
#include #include #include #include #include int main() { float v, a, r, Vxo, Vyo, g, tof, t, Vx, x, y, Vy, ti; printf("Enter a velocity: "); scanf("%f", &v); printf("Enter an angle in degrees: "); scanf("%f", &a); printf("--- Input Information ----------------"); printf(" Initial Velocity Vo = %6.2f",v ); printf(" Angle in Degree = %6.2f" ,a ); printf(" --------------------------------------"); r = a * M_PI/180; printf(" Angle in radian = %6.2f", r ); Vxo = v * cos(r); printf(" Initial Horizontal Velocity = %6.2f", Vxo); Vyo = v * sin(r); printf(" Initial Vertical Velocity = %6.2f", Vyo); g = 9.80665; tof = (2 * v * sin(r))/g; printf(" Time of Flight = %6.2f", tof); printf(" Input a given time interval (ti): "); scanf("%f", &ti); printf(" -------------------------------------------------------------------------------------- "); printf(" Time Horizontal Distance Vertical Distance Vertical Velocity "); ti = 0; while (ti < 0.99) { Vx = Vxo; x = Vx * ti; y = Vyo * ti - (.5) * g * pow(ti,2); Vy = Vyo - g * ti; printf("%6.2f %6.2f %6.2f %6.2f ", ti, x, y, Vy); ti = ti + 0.01; } ti = 0; while (ti <=4.00) { Vx = Vxo; x = Vx * ti; y = Vyo * ti - (.5) * g * pow(ti,2); Vy = Vyo - g * ti; printf("%6.2f %6.2f %6.2f %6.2f", ti, x, y, Vy); ti = ti + 0.50; printf(" "); } printf(" "); ti = 5.00; while (ti <=8.00) { Vx = Vxo; x = Vx * ti; y = Vyo * ti - (.5) * g * pow(ti,2); Vy = Vyo - g * ti; printf("%6.2f %6.2f %6.2f %6.2f ", ti, x, y, Vy); ti = ti + 0.50; } printf(" Press any key to exit the program ... "); getche(); }