In C++ Design a class Cannonball to model a cannonball that is fired into the air. A ball has • A flight time after fire

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

In C++ Design a class Cannonball to model a cannonball that is fired into the air. A ball has • A flight time after fire

Post by answerhappygod »

In C++
Design a class Cannonball to model a cannonball that is fired into
the air. A ball has • A flight time after fired. • An x- and a
y-position. • An x- and a y-velocity. Supply the following member
functions: • A constructor with the appropriate variables
initialized. Assume the cannonball starts at the origin (0,0). • A
member function move(double sec) that moves the ball to the next
position for a given time increment (sec). Using the projectile
motion formula and assuming negligible air resistance. Considering
the gravitational acceleration of –9.81 m/sec2. 1. First compute
the distance traveled in seconds, using the current velocities,
then update the x- and y-positions. 2. Then update the y-velocity;
the x-velocity is unchanged. 3. Move should not print anything to
the console. • A member function shoot whose parameters are the
angle a and initial velocity v 1. Compute the x-velocity as
v*cos(a) and the y-velocity as v*sin(a). 2. Then keep calling move
with a time interval of 0.1 seconds until the y-position is ≤ 0 3.
Display the (x, y) position and flight time after every 10 moves
and when the ball hits the ground. Use setw(8) and setprecision(2)
to format the positions; Use setw(4) and setprecision(1) to format
the times. Use this class in a program that prompts the user for
the starting angle and the initial velocity. Then call shoot.
Requirements: 1. You must submit three c++ files: 1. one header
(.h) file containing the declaration of the class, 2. one .cpp file
containing the member functions, 3. one .cpp file containing the
main function. 2. Both move and shoot should be void functions. The
only input to either should be (double sec) to move. 3. Return a
termination message when the ball hits the ground 4. Please test
for an angle of 30° and 100 m/sec launch velocity. All units can be
assumed to be metric.
In C Design A Class Cannonball To Model A Cannonball That Is Fired Into The Air A Ball Has A Flight Time After Fire 1
In C Design A Class Cannonball To Model A Cannonball That Is Fired Into The Air A Ball Has A Flight Time After Fire 1 (186.78 KiB) Viewed 77 times
In C Design A Class Cannonball To Model A Cannonball That Is Fired Into The Air A Ball Has A Flight Time After Fire 2
In C Design A Class Cannonball To Model A Cannonball That Is Fired Into The Air A Ball Has A Flight Time After Fire 2 (138.2 KiB) Viewed 77 times
. . Design a class Cannonball to model a cannonball that is fired into the air. A ball has A flight time after fired. An X- and a y-position. An x- and a y-velocity. Supply the following member functions: A constructor with the appropriate variables initialized. Assume the cannonball starts at the origin (0,0). A member function move(double sec) that moves the ball to the next position for a given time increment (sec). Using the projectile motion formula and assuming negligible air resistance. Considering the gravitational acceleration of -9.81 m/sec2 1. First compute the distance traveled in seconds, using the current velocities, then update the x- and y-positions. 2. Then update the y-velocity; the x-velocity is unchanged. 3. Move should not print anything to the console. A member function shoot whose parameters are the angle a and initial velocity v 1. Compute the x-velocity as v*cos(a) and the y-velocity as v*sin(a). 2. Then keep calling move with a time interval of 0.1 seconds until the y-position is so 3. Display the (x, y) position and flight time after every 10 moves and when the ball hits the ground. Use setw(8) and setprecision(2) to format the positions; Use setw(4) and setprecision(1) to format the times. Use this class in a program that prompts the user for the starting angle and the initial velocity. Then call shoot. Requirements: 1. You must submit three c++ files: 1. one header (.h) file containing the declaration of the class, 2. one .cpp file containing the member functions, 3. one .cpp file containing the main function. 2. Both move and shoot should be void functions. The only input to either should be (double sec) to move. 3. Return a termination message when the ball hits the ground 4. Please test for an angle of 30° and 100 m/sec launch velocity. All units can be assumed to be metric.

Ex: Please enter the starting angle: 30 Please enter the initial velocity of the cannonball: 100 The x and y positions are: 86.60m and 45.09m, respectively, after 1.0s The x and y positions are: 173.21m and 80.38m, respectively, after 2.0s The X and y positions are: 259.81m and 105.85m, respectively, after 3.0s The x and y positions are: 346.41m and 121.52m, respectively, after 4. Os The x and y positions are: 433.01m and 127.37m, respectively, after 5.0s The x and y positions are: 519.62m and 123.42m, respectively, after 6.0s The X and y positions are: 606.22m and 109.65m, respectively, after 7.05 The x and y positions are: 692.82m and 86.08m, respectively, after 8.0s The x and y positions are: 779.42m and 52.69m, respectively, after 9.0s The x and y positions are: 866.03m and 9.50m, respectively, after 10.0s The x and y positions are: 883.35m and -0.32m, respectively, after 10.2s
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply