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

7. Write a program that follows the flight of a golf ball, in intervals of 0.1 s

ID: 3586474 • Letter: 7

Question

7. Write a program that follows the flight of a golf ball, in intervals of 0.1 seconds. We know that its height above the ground, y, its distance, x, and its velocity in the vertical direction, v, are given by the following relations with respect to the time, t, from the start of the flight. 58.50t ft y= 83.55t-16t' ft v83.55-32t ft/sec Use a while loop to calculate and Idisplay the values of t, x, y and v in a table with labeled columns, so long as, y remains positive and the velocity stays greater than-60 ft/sec. HINT: You may need to initialize variables to get into the loop. 8. In cosmology the behavior of space through time is given by a function called the scale factorr(t). The variable, t, is related to time and has the range 0 to 2pi with interval 0.01. The Freedman model predicts three possible behaviors of the scale factor depending upon estimates of the amount of matter in the universe. The amount of matter depends on a factor known as Epsilon (E) being 0, +1 or -1. With E -0 then r(t) -Gt/2 with E--1 then r (t) =G(cosh (t) -1) with E-+1 then r(t)G(1-cos (t)). G is related to Newton's gravitational constant and G 64000. Write a program that wi11 asks the user for the epsilon value from which the curve of r versus t will be produced within the iven time interval. The program should terminate if the user enters a non-valid value of E. HINT: The while loop should be controlled with or' logic for the three values of E. Run the program for all three epsilon cases, as well as, termination to be sure it is working. USE WHILE loop and If -elseif else structure.

Explanation / Answer

7

#include<iostream>
#include<iomanip>

using namespace std;

int main(){

   double x,y,v,t;

   t = 0;
   cout << setw(10) << "t" << setw(10) << "x" << setw(10) << "y" << setw(10) << "v" << endl;
   y = 1;
   v = 0;
   while ( y >= 0 && v > -60){
      x = 58.5 * t;
      y = 83.55*t-16*t*t;
      v = 83.55-32*t;
      cout << setw(10) << t << setw(10) << x << setw(10) << y << setw(10) << v << endl;  
      t = t + 0.1;


   }
}

8.

#include<iostream>
#include<math.h>
#include<iomanip>


using namespace std;

int main(){

   int e;
   double t;
   double r;
   double G = 64000;

   cout << "Enter value of E :";
   cin >> e;
   t = 0;

   if (e == 0){
      cout << setw(5) << "t" << setw(20) << std::right << "r(t) ";
      while (t <= 2 * M_PI){
          r = G*t/2;
          cout << setw(5) << t << setw(20) << std::right << r << endl;
          t = t + 0.01;
      }
   } else if (e == -1){
      cout << setw(5) << "t" << setw(20) << std::right << "r(t) ";
      while (t <= 2 * M_PI){
          r = G*(cos(t) -1);
          cout << setw(5) << "t" << setw(20) << std::right << r << endl;
          t = t + 0.01;
      }
   } if (e == 1){
      cout << setw(5) << "t" << setw(20) << std::right << "r(t) ";
      while (t <= 2 * M_PI){
          r = G*(1 - cos(t));
          cout << setw(5) << "t" << setw(20) << std::right << r << endl;
          t = t + 0.01;
      }
   }
   else {
       cout << "Invalid value ";
       return 0;
  
   }

   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