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

object travels along a straight path and its initial velocity vo-0. Its accelera

ID: 3599710 • Letter: O

Question

object travels along a straight path and its initial velocity vo-0. Its acceleration (in m/s) as a function of time is given. Since acceleration is the time derivative of velocity-de use numerical integration method to calculate the velocity v at any time, t, entered by the user. The step size of the integration must be set at 0.001 s. The program will also give an error message if the time entered by the user is out of range. Below are several example running outcomes. Your outputs might be a little different but should be close enough. (25 points) 2. An dt 0.7t 0St

Explanation / Answer

#include<iostream>

using namespace std;

int main(){

   double time;
   double count,v;
   cout << "Enter the value of time:";
   cin >> time;
   while (time < 0 || time >=30){
      cout << "Plese enter valid time ( 0<= t < 30):";
      cin >> time;
   }
   if (time < 10){
       v = 0;
       count = 0.001;
       while (count <= time){
            v = v + 0.7*0.001;
            count = count + 0.001;
       }
       cout << "The velocity is " << v << endl;
   }
   if (time >= 10 && time < 20){
      v = 0;
       count = 0.001;
       while (count <= time){
          if (count < 10){
            v = v + 0.7*0.001;
          }
          else {
             v = v+1.8;
          }
          count = count + 0.001;
       }
       cout << "The velocity is " << v << endl;
   }
   if (time >= 20 && time < 30){
       while (count <= time){
          if (count < 10){
            v = v + 0.7*0.001;
          }
          if (count >= 10 && count < 20) {
             v = v+1.8;
          }
          count = count + 0.001;
       }
       cout << "The velocity is " << v << endl;
   }
}