Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Karyn Czapnik HW #7
- #include <iostream>
- #include <math.h>
- #include <iomanip>
- using namespace std;
- double theNewVelocity (double dragCoefficient, double velocity);
- double yposition (double velocity, double angle, double time);
- int main ()
- {
- double drag, velocity, position, time;
- cout << "Enter the coefficient of drag (between 1e-4 and 1e-6):";
- cin >> drag;
- velocity = 1200;
- double angle = 40;
- double pi = 3.14;
- double rad = angle*(pi/180);
- int spaces = int (yposition (velocity, rad, time));
- cout << setw(spaces) << "* \n";
- double newVelocity = theNewVelocity (drag, newVelocity);
- for (time=2; time<50; time=time+2)
- {
- if (time==2){
- yposition (theNewVelocity (drag, velocity), rad, time);
- }
- else (time>2){
- yposition (theNewVelocity (drag, newVelocity), rad, time);
- cout << "* \n";
- }
- }
- }
- double theNewVelocity (double dragCoefficient, double velocity)
- {
- double velocity1 = dragCoefficient*(velocity*velocity);
- double velocitynow = velocity1-velocity;
- return velocitynow;
- }
- double yposition (double velocity, double angle, double time)
- {
- double a = 9.81;
- double yposition = (velocity*time*sin(angle))-(.5*a*(time*time));
- return yposition;
- }
Add Comment
Please, Sign In to add comment