I have asked this question preivously on Physics site of Stack Exchange Link but since got little attention and suggestion I am posting this question here.Question:
After fixing some problems after @PM2Ring's commentsuggestion on Linkother site.
double semiMajorAxis = 1.5237 * 149598000;
double eccentricty = 0.0934;
double current_time = 0;
double last_speed;
double angular_distance = 0; // unit : rad
boolean stop = false;
double last_day_distance = 0;
double avg_speed = 0;
double distance_in_km;
double last_day_angular_distance = 0;
while (!stop) {
double radius = get_radius(angular_distance, eccentricty, semiMajorAxis);
last_speed = (get_speed(radius * 1000, semiMajorAxis * 1000) / radius);
angular_distance += last_speed;
distance_in_km = angular_distance * radius;
current_time += 1;
if (angular_distance >= Math.PI * 2) {
System.out.println("Total days : " + current_time / 60 / 60 / 24);
stop = true;
}
}