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

i just need number 2 i use c++ Programs Due 4/25 17 (50% of testl The following

ID: 3825071 • Letter: I

Question

i just need number 2 i use c++

Programs Due 4/25 17 (50% of testl The following formula can be used to determine the displacement of an object d Vo't -1/2 at where ve is initial velocity and is 5m/s, a is acceleration and is 3.5 m/s2 tis the time in seconds and d is the displacement or distance travelled in meters and will be computed Compute d by 1. Sending an objects travelling time into a function named displacement that accepts the object's travelling time (in seconds) as an argument. The function should return the distance, in meters, that the object has been displaced or moved 2. The call to this function will be placed inside of a loop in the main function that iterates time from 1 to 10. The call to the displacement function with time being the argument will be made each time the loop is passed through. The function will compute displacement and return the value to the main. A new value of t is passed into the function each time the loop is repeated with a new value of t as the argument to the function. Return value of the distance in a cout statement that indicates the distance for the corresponding value of

Explanation / Answer

Code:

#include <iostream>
using namespace std;

// function declaration
float calDisplacement(int t);

int main() {
for(int time=1;time<=20;time++)
cout << "Displacement is : " << calDisplacement(time) << endl;
return 0;
}

// function to calculate displacement of the object
float calDisplacement(int t) {
int v0 = 5;
float a = 3.5;

// formula : d = v0 * t + 1/2 * a * t^2
float d = v0 * t + 0.5 * a * (t*t);

return d;
}

Output:

NOTE: In your screenshot i could see the formula is wrong for calculating displacement. There is a '=' instead of '+'. I corrected it and the formula is d= v0*t + 1/2 * a * t^2