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

#include<iostream> //Required for cin,cout #include<iomanip> //Required for setp

ID: 3805273 • Letter: #

Question

#include<iostream> //Required for cin,cout
#include<iomanip> //Required for setprecision(), setw()
#include<cmath> //Required for pow()
using namespace std;
int main()
{
// Declare objects.
double time, velocity, acceleration;

// Get time value from the keyboard.
cout << "Enter new time value in seconds: ";
cin >> time;
velocity = 0;
acceleration = 0;
// Compute velocity and acceleration.
while (time < 200)
{
  if (time < 100)
  {
   velocity = 0.00001*pow(time, 3) - 0.00488*pow(time, 2)
    + 0.75795*time + 181.3566;
   acceleration = 3 - 0.000062*velocity*velocity;
  }
  else
  {
   velocity = 2 * pow(time, 2) + ( pow(90*time, 0.5));
   acceleration = 9 * velocity + log(time);
  }
  time = time + 20;

  // Print time, velocity and acceleration.

  cout << fixed << setprecision(3);
  cout << "time= " << time << " sec" << endl;
  cout << "Velocity = " << setw(10)
   << velocity << " m/s" << endl;
  cout << "Acceleration = " << setw(14)
   << acceleration << "m/s^2" << endl << " ";
}
system("pause");
// Exit program.
return 0;
}

HAND IN LABORATORY TASK: LAB #11 load the PREVIOUS ifwhile1 program MODIFY With "else" velocity 32 time2 (90 time) 1/2 acceleration -9 velocity+log (time) USE pow0, Sqrt0,logo Run and attach output for times 150,30 WITH THE printed program Write comments on the final printed outputs that show the value of time as follows: Use a pencil! This is called playing computer with the control variable (time" here!) (ie "condition" on time controls the while and the if/else) 1. Comment as to what part of the "ifelse" structure is doing the calculations of acceleration and velocity for each output (that is (if or else? Or neither?) and write the values of 'time' that was used to calculate the output? for each output write time Warning the output of time is deliberately not the correct value used to Calculate in most lines. 2. What was the value of time that ended the loop for each input. That is show the exit point and the time value for each input. Careful detailed analyze for the above 3. Hand in a flow chart on this assignment THis IS VERY IMPORTANT!

Explanation / Answer

on compiling your code it was giving the below error

error: 'system' was not declared in this scope                                                                                        

  system("pause");   

i have included the header file #include<cstdlib> and now it is running

#include<iostream> //Required for cin,cout
#include<iomanip> //Required for setprecision(), setw()
#include<cmath> //Required for pow()
#include<cstdlib>
using namespace std;
int main()
{
// Declare objects.
double time, velocity, acceleration;
// Get time value from the keyboard.
cout << "Enter new time value in seconds: ";
cin >> time;
velocity = 0;
acceleration = 0;
// Compute velocity and acceleration.
while (time < 200)
{
if (time < 100)
{
velocity = 0.00001*pow(time, 3) - 0.00488*pow(time, 2)
+ 0.75795*time + 181.3566;
acceleration = 3 - 0.000062*velocity*velocity;
}
else
{
velocity = 2 * pow(time, 2) + ( pow(90*time, 0.5));
acceleration = 9 * velocity + log(time);
}
time = time + 20;
// Print time, velocity and acceleration.
cout << fixed << setprecision(3);
cout << "time= " << time << " sec" << endl;
cout << "Velocity = " << setw(10)
<< velocity << " m/s" << endl;
cout << "Acceleration = " << setw(14)
<< acceleration << "m/s^2" << endl << " ";
}
system("pause");
// Exit program.
return 0;
}