Guest User

Untitled

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