Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with my Programming class. Here are some code I wrote down but incomplete. #include #include #include const double pi = 3.14159265358979323846264338327950288419716939937510; //pi

I need help with my Programming class. Here are some code I wrote down but incomplete.

#include

#include

#include

const double pi = 3.14159265358979323846264338327950288419716939937510; //pi constant

const double g = 9.81; //gravity constant

double deg_to_rad(double d_angle) // converting degree to rad

{

return pi*d_angle / 180.0; // convert deg to rad and return rad

}

double x_velocity(double init_v, double init_deg)

{

return init_v*cos(init_deg);

}

double y_velocity(double init_v; double init_deg; double tf)

{

return (init_v*sin(init_deg))-(g*tf);

}

int main(void)

{

double tf, init_v, init_deg, height, init_x, time_increment_current_t;

int data_rows;

std::cout << "This program calculates the trajectory of a paintball. " <

std::cout << "The time will start at t=0s.What is the final time in seconds?" <

std::cin >> tf;

std::cout << "How many rows of data do you want in the table?Please enter an int." <

std::cin >> data_rows;

std::cout << "What is the initial velocity in m/s (100 m/s is typical)?" <

std::cin >> init_v;

std::cout << "What is the initial angle in degrees?" <

std::cin >> init_deg;

std::cout << "What is the height of the paintball marker barrel in m?" <

std::cin >> height;

std::cout << "What is the initial x or horizontal distance in feet (0 m typical)?" <

std::cin >> init_x;

time_increment = (tf-0) / (double)(data_rows-1);

calculation mycalc;

curent_t = 0.0;

std::cout << " for loop ";

std::cout << " Data Table " << "Angle (deg)" << "sincostan ";

std::cout << std::fixed << std::setprecision(5);

for (int i(0); i

{

std::cout << "inside the for loop, time = " << current_t << std::endl;

current_t = current_t + time_increment;

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

who should be responsible for customer contact management?

Answered: 1 week ago