double energy, mass;
double speedOfLight = 299792458.0;
// Get mass
System.out.print("Mass? ");
mass = keyboard.nextDouble();
// Calculate energy
energy = mass*Math.pow(speedOfLight, 2);
// Round to 1 decimal place
energy = Math.round(energy * 10.0) / 10.0;
System.out.printf("The energy is " +energy+ " Joules");
// Close scanner
keyboard.close();
It is returning, "The energy is 8.987551787368176E16 Joules" when it should be returning, "The energy is 89875517873681760.0 Joules"