Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with the following C-program: I need this program to output only when I input (ti) a value from 0 to 8.00. everything

I need help with the following C-program:

I need this program to output only when I input (ti) a value from 0 to 8.00.

everything seems to work great as it is but my issue is that even when I input 9.00 I will get an output.

Velocity is 40 and angle is 70

thanks!

#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 "); if (ti < 1.0) { 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 = 1.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(); }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

More Books

Students also viewed these Databases questions

Question

internationalization of business?

Answered: 1 week ago