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

The overview is to take some input, with error checking using loops and conditio

ID: 3785469 • Letter: T

Question

The overview is to take some input, with error checking using loops and conditional statement,then transform the input into a ballistic calculation and output the result. The instructor is not helping me to understand the subject so I don't know how to do it, if someone could help me to do this and explaining this at the same time, i would be able to finally understand what to do in the class!!. Thanks so much Display a welcome message. Prompt for the height above ground (we're assuming a flat firing arca) and accept anything above 0 (you can set a reasonable upper limit, such as l mile, if you wish). lf the input is out of the acceptable range, print an error message and repeat the input until an acceptable value is input. 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. 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. For your output, restate the user's inputs and then display the time and distance to impact. 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. Show your testing. Show inputs that trigger your error messages and show a couple of runs with good inputs.

Explanation / Answer

#include <stdio.h>
#include <math.h>

int main()
{
float height,angle,velocity,v_velocity=0,h_velocity=0,g=9.8;
float time_return=0,time_continue=0,time_impact=0,distance_impact=0;
printf(" *****WELCOME***** "); //welcome message
do
{
printf(" Enter height above ground(in meters): "); //prompt user to get height
scanf("%f",&height); //taking value of height from user
if(height<1 || height>1609) //if height is not between range print the error message
printf(" ERROR: height sholud be less than 1 mile and greater tha 0");
}while(height<1 || height>1609); //loop until the correct height is entered
do
{
printf(" Enter firing angle: "); //prompt user to get angle
scanf("%f",&angle); //taking value of angle from user
if(angle<=-90 || angle>=90)//if angle is not between range print the error message
printf(" ERROR: angle should be between -90 to 90");
}while(angle<=-90 || angle>=90);
printf(" Enter initial velocity: ");
scanf("%f", &velocity);
v_velocity=sin(angle)*velocity;
h_velocity=cos(angle)*velocity;
if(angle>=0)
time_return=(2*v_velocity)/g;
time_continue=(height*16)/(velocity*15);
time_impact=time_return+time_continue;
distance_impact=time_impact*h_velocity;
//output
printf(" Height above ground(in meters): %f",height);
printf(" Firing angle: %f",angle);
printf(" Initial velocity: %f",velocity);
printf(" Vertical velocity: %f",v_velocity);
printf(" Horizontal velocity: %f",h_velocity);
printf(" Time to return: %f",time_return);
printf(" Time to continue: %f",time_continue);
printf(" Time to impact: %f",time_impact);
printf(" Distace to impact: %f",distance_impact);
  
  
return 0;
}

as per the instructions the equations are implied

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote