This program simulates the motion of the components of a two stroke engine. It shows the movement of piston, connecting rod and crank by animating them in java. The program override the paint method of a JFrame to simulate the piston movement in two stroke engine. This can be computer graphics lab (CG lab) problem. The program is as given below. The program uses sin and cos functions to simulate the crank. Also it uses the equation to find the distance between to points.