Problem Using Large Numbers
This program is ment to calculate how long it would take for an object to fall to the center of a planet, however, 5.9742*10^24 kg (the mass of earth) is too large for Java, and bigDecimal is making things far too complicated. Is there a simple way to do this?
class Acceleration
{
publicstaticvoid main(String arguments[])
{
// kg // m // s //
double mass = 5974200000000000000000000;
double distance = 6378100;
double gravity = mass / (distance * distance) * 0.00000000006673;
double traveled = 0;
double speed = 0;
double time = 0;
while(traveled<1)
{
speed += gravity;
traveled += speed;
time++;
}
System.out.println("Traveled: " + traveled +" m");
System.out.println("Time: " + time +" s");
System.out.println("Final Speed: " + speed +" m/s");
}
}
Also, I know the program is incomplete, but I'd like to resolve this problem before finishing it.

