#include <iostream>
using namespace std;
//calc F
float force(float pos, float vel);
//Basic Euler Numerical Integration
int main(void)
{
	float x = 0.0f; //starting position at 0m
	float v = 0.0f; //starting velocity 0m/s
	float m = 1.0f; //mass = 1kg
	float F = 0.0f; //Applied force is 5N
	float h = 0.01; //time in seconds. Time step delta
	float accel = F / m; //acceleration im m/s/s
	float time = 0.0f; //elapsed time in seconds
	cout << "step   time (s) position(m) velocity(m/s)" << endl;
	for (int i = 0; i < 10; i++) 
	{
		F = force(x, v);
		x = x + h * v;  //new position
		v = v + h * accel;//new velocity
		time = time + h; //elapsed time
		cout << i << "  " << time << "     " << x << "   " << v << endl;
	}
	return 0;
}
//calculates the force on a body
float force(float pos, float vel)
{
	//Exercise: Set force to 1N until 5 metres has elapsed 
	//then set force to 0N until 6 metres has elapesed
	//then decelerate with a force of 2N until velocity=0m/s
	return 5.0;
}