Guest User

Untitled

a guest
Jul 17th, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. //Karyn Czapnik HW #7
  2. #include <iostream>
  3. #include <math.h>
  4. #include <iomanip>
  5.  
  6. using namespace std;
  7.  
  8. double theNewVelocity (double dragCoefficient, double velocity);
  9. double yposition (double velocity, double angle, double time);
  10.  
  11. int main ()
  12. {
  13. double drag, velocity, position, time;
  14. cout << "Enter the coefficient of drag (between 1e-4 and 1e-6):";
  15. cin >> drag;
  16. velocity = 1200;
  17. double angle = 40;
  18. double pi = 3.14;
  19. double rad = angle*(pi/180);
  20. int spaces = int (yposition (velocity, rad, time));
  21. cout << setw(spaces) << "* \n";
  22. double newVelocity = theNewVelocity (drag, newVelocity);
  23.  
  24. for (time=2; time<50; time=time+2)
  25. {
  26. if (time==2){
  27. yposition (theNewVelocity (drag, velocity), rad, time);
  28. }
  29. else (time>2){
  30. yposition (theNewVelocity (drag, newVelocity), rad, time);
  31. cout << "* \n";
  32. }
  33. }
  34. }
  35.  
  36. double theNewVelocity (double dragCoefficient, double velocity)
  37. {
  38. double velocity1 = dragCoefficient*(velocity*velocity);
  39. double velocitynow = velocity1-velocity;
  40. return velocitynow;
  41. }
  42.  
  43. double yposition (double velocity, double angle, double time)
  44. {
  45. double a = 9.81;
  46. double yposition = (velocity*time*sin(angle))-(.5*a*(time*time));
  47. return yposition;
  48. }
Add Comment
Please, Sign In to add comment