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

I believe I am supposed to use loops in this program but I am not really sure ho

ID: 3623395 • Letter: I

Question

I believe I am supposed to use loops in this program but I am not really sure how to write any of it. Please help! Will rate lifesaver if all is correct!
_________________________________________________________________________



For this assignment, write a program that will analyze the data from a physics experiment.

The data consists of a series of position measurements for a moving object. The position measurements will be entered by the user of the program as they are continually prompted. Each of the position measurements that the user enters will have been recorded at uniform time intervals. This time interval will be entered by the user when the program begins and will be followed by the series of position measurements. Each position should be greater than or equal to the previous position because the object is either moving in one direction or still, but never moving backwards. Therefore a negative position measurement will be used to signal the end of the user's data for the run of the program.

After each of the position measurements has been entered, calculate and display the following:

1. the average velocity for the time interval

2. the average acceleration for the time interval

Calculations

Use the following formulas for the calculations:

change of position = current position - previous position

change of velocity = current velocity - previous velocity

average velocity = change of position / time interval

average acceleration = change of velocity / time interval

Notes

1. The starting position and starting velocity should both be 0.
2. There should be a loop to validate the position entered by the user. As stated earlier, each position that the user enters must be greater than or equal to the previous position. Each time the user enters an invalid position, an error message that includes the invalid position as well as the previous valid position should be displayed and the user should be given a chance to enter the current position again.

Processing Requirements

1. At the top of the C++ source code, include a documentation box that resembles the ones from programs 1 and 2.

2.The program should be fully documented.

3. Use meaningful variable names.

4. Make sure and test the program with values other than the ones in the Sample Output.








Sample Output

Motion Analysis

Enter the uniform time interval in seconds: 2.5



Enter a position in feet (negative value to quit): 2

Average velocity (this interval): 0.80 feet/second
Average acceleration: 0.32 feet/second/second



Enter a position in feet (negative value to quit): 5

Average velocity (this interval): 1.20 feet/second
Average acceleration: 0.16 feet/second/second



Enter a position in feet (negative value to quit): 4

Invalid value: 4 is less than the current position of 5. Try again.



Enter a position in feet (negative value to quit): 12


Average velocity (this interval): 2.80 feet/second
Average acceleration: 0.64 feet/second/second



Enter a position in feet (negative value to quit): -1

Explanation / Answer

Heya! I used functions, but it isn't necessary, but makes the code cleaner. Hope this is what you have been looking for! ------------------------------------------------------------------------------------------------------- //The physics student trying to be programmers Program :-P //The header file that contains all the code for your input and output needs #include //The library of awesum standard C++ functions using namespace std; //function to calculate the change of position double changePosition(double currentPos, double prevPos) { return (currentPos - prevPos); } //function to calculate the change of velocity double changeVelocity(double currentVel, double prevVel) { return (currentVel - prevVel); } //function to calculate the average Velocity double averageVelocity(double time, double prevPos, double currentPos) { return (changePosition(currentPos, prevPos)/time); } //function to calculate the average acceleration double averageAcceleration (double time, double prevVelocity, double currentVelocity) { return (changeVelocity(currentVelocity, prevVelocity)/time); } //your main function where all the magic happens :-P int main() { //I used doubles, because doubles can hold large fractions double timeInterval; //Variable to store the uniform time interval double prevPos = 0; //variable to store the previous position double curPos = 0; //variable to store the current position double prevVel = 0; //variable to store the previous velocity double curVel = 0; //variable to store the current velocity bool flag = true; //If the position is a negative, flag becomes true and the program will cease to exist :-) //Asking for the time interval, you can change the seconds to minutes, milliseconds etc... cout > timeInterval; cout
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