d=(v²*sin(2a))/g t=d/(v*cos(a)) h=(g(t/2)²)/2 Where d is the distance traveled b
ID: 3623529 • Letter: D
Question
d=(v²*sin(2a))/g
t=d/(v*cos(a))
h=(g(t/2)²)/2
Where
d is the distance traveled by the ball in meters.
a is the angle from the ground the cannon is pointed.
v is the intial velocity of the ball leaving the cannon in m/s.
g is the gravitational constant of 9.81 m/s/s.
t is the time the ball is in the air in seconds.
h is the maximum height the ball reaches in meters.
This assignment will test your knowledge of: writing formatted results to an external file, using cmath functions in assignment statements, using external void and single result functions, using a loop (you can choose which kind to use), and using an if else block; This will cover material up to and including Chapter 2.10.NOTE: Do not use a function called distance. distance is a reserved word in the std namespace.
Write a C++ program named xxxxpa2.cpp that does the following:
a. Asks the user for the distance of a target.
b. Asks the user for an angle from the horizontal that the cannon is aimed and fired.
c. Calls a void function that calculates the distance traveled, the maximum height reached, and the time traveled of the cannon ball for initial velocities of 10, 20, 30, and 40 m/s. Each of the three values (d, h, t) must be calculated using three separate single result functions.
d. Also in the void function the program checks to see if the cannon ball is within 1 meter of the target.
e. Repeats b. c. and d. for a total of 3 angles input by the user, without ending the program.
f. The void function also prints out three tables, one for each angle of the cannon to the screen and to a file named report.txt. (NOTE: This will require you to open the report.txt file above the main function so that it is globally available. If you do not, you will not be able to write all three cases of angles to the file.
g. Each table should have the following format: The table heading lists the angle and other text to identify the table columns:
Column one is the initial velocity in m/s.
Column two is the maximum height reached in meters.
Column three is the time traveled in seconds
Column four is the final distance in meters.
Column five says HIT if the ball is within 1 meter of the target and MISS if it is not.
Each table will have 4 rows (not counting the heading), one for each value of initial velocity.
Give two digits to the right of the decimal point for all outputted results.
Explanation / Answer
the numbers are slighly different because you didn't specify what to use for PI #include #include #include #define g 9.81 #define PI 22./7. using namespace std; void traveled(double,double,double&,double&,double&); double dist(double,double); double height(double); double time(double,double,double); int main() {double target,angle,vzero,ht,t,d; couttarget; coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.