ok, please don't laugh too hard with my stupid codes,,,,,
********************************************
Requirments:
Calculations
Use the following formulas for your calculations:
average velocity = change of position / time interval
average acceleration = change of velocity / time interval
Processing Requirements
At the top of your C++ source code, include a documentation box that resembles the ones from programs 1 and 2.
Notice (in the Sample Output below) that there are line numbers before each prompt for a position measurement. But also notice that the number does not change when invalid data is entered.
Sample Output
Motion Analysis
Enter the uniform time interval in seconds: 2.5
1. Enter a position in feet (negative value to quit): 2
Average velocity (this interval): 0.80 feet/second
Average velocity (all intervals): 0.80 feet/second
Average acceleration: 0.32 feet/second/second
2. Enter a position in feet (negative value to quit): 5
Average velocity (this interval): 1.20 feet/second
Average velocity (all intervals): 1.00 feet/second
Average acceleration: 0.16 feet/second/second
3. Enter a position in feet (negative value to quit): 4
Invalid value: 4 is less than the current position of 5. Try again.
3. Enter a position in feet (negative value to quit): 12
Average velocity (this interval): 2.80 feet/second
Average velocity (all intervals): 1.60 feet/second
Average acceleration: 0.64 feet/second/second
4. Enter a position in feet (negative value to quit): -1
************************************************** ***
Codes
int main()
{
float timeinterval;
int intervalcount=1;
float position, positiona, positionb;
float avgvelocity, avgvelocityb;
float avgvelocityall;
float avgacceleration;
cout <<"Please enter the uniform time interval in second: ";
cin >> timeinterval;
cout <<"Please enter a postion in feet (negative value to quit): ";
cin>> positiona;
avgvelocity= (double)(positiona)/timeinterval;
avgvelocityall=(double)(positiona)/(timeinterval*intervalcount);
avgacceleration=(double)(avgvelocity)/(timeinterval);
intervalcount++;
cout <
cout <
cout <
cout<
cout <<"Please enter a postion in feet (negative value to quit): ";
cin>> positionb;
while (positiona>0 and positionb>0)
{
if (positionb
{
cout <
}
else
{
position=positionb-positiona;
avgvelocityb= (double)(position)/timeinterval;
avgvelocityall=(double)(positionb)/(timeinterval*intervalcount);
avgacceleration=(double)(avgvelocityb-avgvelocity)/(timeinterval);
intervalcount++;
cout <
cout <
cout <
}
cout <
cout <<"Please enter a postion in feet (negative value to quit): ";
cin>> positionb;
}
return 0;
}
Thanks again