Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please can someone help me to finish this program? It is a C programming not a C

ID: 3790315 • Letter: P

Question

Please can someone help me to finish this program? It is a C programming not a C++, when programming the program in linux I keep getting expected expression before || token, also please check if everything else is fine, maybe there is something else worng in my program and may ask me later to fix it, I am concern about the sin and cosine. The program is supposed to do all this:

1.Display a welcome message.

2.Prompt for the height above ground (we’re assuming a flat firing area) and accept anything above 0 (you can set a reasonable upper limit, such as 1 mile, if you wish). If the input is out of the acceptable range, print an error message and repeat the input until an acceptable value is input.

3.Similarly, prompt for the firing angle and accept between 90 and -90.

And, finally, prompt for the initial velocity (we’ll assume there is no acceleration due to firing or wind resistance). Pay attention to units; if your calculations are in meters and seconds, don’t prompt for feet and minutes unless you want to do the conversions.

4.Calculate the time and distance to impact. You’ll need to get the vertical and horizontal velocity vectors from the firing angle and the initial velocity. If the angle is positive, the time to return to the same height is 2 * initial vertical velocity / g. The time to continue to the ground is (height * 16) / (velocity * 15). This is a rough approximation but is good enough for this project. Add the two times together to get the time to impact and then multiply that by the horizontal velocity to get the distance to impact.

5.For your output, restate the user’s inputs and then display the time and distance to impact.

6.Prompt the user to see if they want to do another calculation and, depending on their input, return to the beginning or exit the program

And this is the program please any suggestions in the error that I am getting?? I rreally want this to compile and execute

C He Ale Options utters Tool A a include td ude nath tuoat eight angle, velocity, v velocity h velocity 9, 8 float tine e-0, tine cont tine inpact e inpact print ("Vn ****ilELCOIEWn')://welcone message intf eight above ground //prompt user to height ght f eight-1 eight 1639 eight i betwee ange print the error ness age mile and greater than whilelheight

Explanation / Answer

The error is due to a syntax mistake in the while conditions. You can replace it with the following code to get rid of the errors:

do{
       printf("Enter height ");
       scanf("%f",&height);
       if((height<1) || height>1609)
printf("Error: height should be less than 1 mile and greater than 0 ");
}while(height<1 || height >1609);
do{
       printf("Enter angle ");
       scanf("%f",&angle);
       if((angle<=-90) || angle>=90)
printf("Error: angle should be between -90 and 90 ");
}while((angle<=-90) || angle>=90);

As you can see, we should not include a ";" before "||" in the while statement. Removing that will result in proper running of the code.