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

Prob-4 Write a computer program that computes the duration of a projectile\'s fl

ID: 3639040 • Letter: P

Question

Prob-4 Write a computer program that computes the duration of a projectile's
flight and its height above the ground when it reaches the target. As
part of your solution, write and call a function that displays instruc-
tions to the program user.
Problem Constant
G = 32.17 // gravitational constant
Problem Inputs
float theta // input - angle (radians) of elevation
float distance // input - distance (ft) to target
float velocity // input - projectile velocity (ft/sec)
Problem Outputs
float time // output - time (see) of flight
float height // output - height at impact

Relevant Formulas
time= distance/(velocity * cos(theta))
g x time2
height = (velocity x sin(theta) x time )-{ (g * time^2)/2}
Try your program on these data sets.
Inputs Data Set 1 Data Set 2
Angle of elevation 0.3 radian 0.71 radian
Velocity 800 ft/sec 1,600 ft/ sec
Distance to target 11,000 ft 78,670 ft


Prob-8 In shopping for a new house, you must consider several factors. In this
problem the initial cost of the house, estimated annual fuel costs, and
annual tax rate are available. Write a program that will determine the
total cost after a five-year period for each set of house data below. You
should be able to inspect your program output to determine the "best
buy."



Initial House Cost Annual Fuel Cost Tax Rate

$175,000 $2500 0.025
$200,000 $2800 0.025
$210,000 $2050 0.020

To calculate the house cost, add the fuel cost for five years to the initial
cost, then add the taxes for five years. Taxes for one year are computed
by multiplying the tax rate by the initial cost. Write and call a function
that displays instructions to the program user and another function that
computes and returns the house cost given the initial cost, the annual
fuel cost, and the tax rate.






Explanation / Answer

/* * Author: Patrick McCarthy * Filename: P34.c * Description: Homework 2, Chapter 3:4, CS261 * This program computes the duration of a projectile's flight * and its height above the ground when it reaches the target. */ #include #include /* Function prototype */ float find_radians(float theta); /* Function prototype */ float calculate_time(float distance, float velocity, float theta); /* Function prototype */ float calculate_height(float velocity, float theta, float time); int main(void) { float degree; float theta; float distance; float velocity; float time; float height; /* Gets the angle of elevation from the user */ printf("Enter angle (in degrees) of elevation =>"); scanf("%f",°ree); printf("%f degrees ", °ree); theta = find_radians(degree); printf("%f radians ", &theta); /* Gets the distance to the target from the user */ printf("Enter distance (in feet) to target =>"); scanf("%f" ,&distance); /* Gets the projectile's velocity from the user */ printf("Enter projectile's velocity (ft/sec) =>"); scanf("%f", &velocity); calculate_time(distance,velocity,theta); /* Displays time of projectile flight to user */ printf("Time of flight is %f seconds. ", &time); calculate_height(velocity,theta,time); /* Displays height of projectile at impact to user */ printf("Height of projectile impact is %f feet from the ground. ", &height); return 0; } /* Converts degrees to radians */ float find_radians(float degree) { float theta; /* local variable */ float Pi = 3.14159; theta = degree * (180/Pi); return (theta); } float calculate_time(float distance,float velocity,float theta) { float time; // local variable time = distance / ( velocity * cos(theta) ); return (time); } float calculate_height(float velocity, float theta, float time) { float height; // local variable float g = 32.17; // Declares acceleration due to gravity as -32 ft/s/s height = velocity * sin(theta) * time - ( (g * time*time) / 2 ); return (height); }
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