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

C++ problem I have the basic outline structure, but wont let me attached anythin

ID: 3668392 • Letter: C

Question

C++ problem

I have the basic outline structure, but wont let me attached anything. But this is the problem below all in all about 48 lines of code

Just need to know loop structures, and also how to input these equations into c++, mine are not working its only reading the first term in each equation.

Approximate lines of code: 48 (does not include comments or white space)

Display to the user the following information/questions:

Enter the distance to the hole (meters):

{ The user will always enter a positive distance.

Enter the launch angle (degrees):

{ The user will always enter a positive angle. and your program must display the answer as:

Valid launch speeds (m/s): XXX where XXX is a list of the valid launch speeds calculated

No valid launch speeds found! if the simulation doesn't find any launch speeds that work.

Assignment Details:

You must develop code to simulate the flight of a golf ball so your golfing robot can perform trick shots! The golng robot is excellent at hitting straight shots, but needs to know the speed to launch the golf ball so it can swing appropriately. The trajectory of the golf ball after being hit can be simulated using equations for projectile motion with drag:

Vx = Vox*exp^(-k*t)

Vy = -g/k + (Voy + g/k)*exp^(-k*t)

X = 1/k * Vox*(1-exp^(-k*t) + Xo

Y = -g*t/k + 1/k * (Voy + g/k) * (1 - exp^(-k*t)) + Yo

You must help the robot hit a trick shot where the ball lands in the hole after 1 bounce! Therefore, you want to nd a launch speed that causes the ball to land slightly before the hole and then bounce in. To simulate a bouncing golf ball, we just need to update the velocity in the y direction at the moment it hits the ground and leave the velocity in x the same:

Vx' = Vx

Vy' -0.35Vy

By combining projectile motion and the golf ball bouncing, our code can nd the best launch speeds for the robot to use!

g = +9.81

k = 0.2

t = simulation time

Xo - initial position

Yo - inital position

Vox - initial speed in x direction

Voy - initial speed in y direction

X(t) - horixontal displacment

Y(t) - vertical displacment

Keys:

-The robot can only control the ball launch speed to a 100th of a m/s, so only simulate speeds to 2 decimal places (i.e. 50.01)

-When dealing with time values, make sure to use small increments! An increment of 0.001 is appropriate.

-The ball will start placed on the ground (y = 0) and will bounce when y reaches 0 again

Sample output:

Enter the distance to the hole (meters): 150

What is the launch angle (degrees)? 36.2

Valid launch speeds (m/s): 50.56 50.57

Explanation / Answer

#include <iostream>

#include <cmath>

using namespace std;

int main ()

{

double vel_50.56 50.57, x_final=0, x_initial=0, time= 0.01,

x_0;

const double G = 150;

const double DELTA_T = 36.2;

cout << "Please input initial velocity of the

cannonball: ";

cin >> vel_50.56 50.57;

while (vel_50.56 50.57 >0)

{

x_initial = x_initial + (vel_50.56 50.57 * DELTA_T);

cout << x_initial;

vel_50.56 50.57 = vel_50.56 50.57 - (G * DELTA_T);

x_0 = -.5 * G * (time * time) +(x_initial * time);

time =+.01;

cout << "The velocity of the cannonball is: " <<

vel_50.56 50.57 << " m/s " << endl;

cout << "The new position of the cannonball is: " <<

x_initial << " ms" << endl;

cout << "The exact position of the cannonball is: "

<< x_150 << " ms_50.56 50.57" << endl_36.2;

}

return 0;

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