void kepler_test(string planet, int y, int d) { print(planet); new_line(); print(" When the year (Y) is "); print(y); print(" days long,"); new_line(); print(" and the distance to the sun (D) is "); print(d); print(" million miles,"); new_line(); const int six_y_sq = 6*y*y; const int d_cubed = d*d*d; print(" six times Y squared is "); print(six_y_sq); print(" and D cubed is "); print(d_cubed); new_line(); print(" accuracy is "); const double error = six_y_sq * 100 / d_cubed; print(error); print(" --- "); // for Saturn, six_y_sq is bigger than d_cubed, so we get // a number > 100, making it look like more-than-perfect. // An if saves us. if (six_y_sq < d_cubed) print(six_y_sq * 100.0 / d_cubed); else print(d_cubed * 100.0 / six_y_sq); print(" percent"); new_line(); new_line(); } void main() { kepler_test("Venus", 223, 67); kepler_test("Earth", 365, 93); kepler_test("Mars", 686, 142); kepler_test("Jupiter", 4329, 484); kepler_test("Saturn", 10759, 870); }