Java program?

Java program?

In order for an object to escape planet's gravitational pull, it must attain a minimum initial velocity called the escape velocity. The escape velocity varies from planet to planet.Create a Java program which calculates the escape velocity for the planet. Your program should first prompt the user for the circumference of the planet and then the acceleration due to gravity on the planet. From this information you determine the radius, mass, and escape velocity of the planet using the following equations:
vescape = square root(2 *G*m/r); g = G m/r^2; G = 6.67x10-11 Nm^2/kg^2.
The console output should look similar to:

Circumference of planet, km? 38000
Acceleration due to gravity, m/s2? 9.8

Calculating the escape velocity?
Planet radius: 6047.9 km
Planet mass: 5372.0 x 10^21 kg
Escape velocity: 10.9 km/s;


***********************This is my code so far******************
import java.util.Scanner;

class EscapeVelocity
{
public static void main( String[] args)
{
double circum;
double accel;

System.out.print("What is the circumference of the planet in km? ");
Scanner scanner= new Scanner(System.in);
circum = scanner.nextDouble();
System.out.print("What is the acceleration due to gravity in m/s^2? ");
scanner= new Scanner(System.in);
accel = scanner.nextDouble();

System.out.println();
System.out.println("Calculating the escape velocity...");
final double PI = 3.14159;// constant value declared
double radius = circum/(2*PI);
System.out.println("Planet Radius: "+ radius+" km");
final double G= 0.0000000000667 ;
double mass = accel*Math.pow(radius,2)/G;
System.out.println("Planet mass: "+ mass+ " kg");
double vescape= Math.sqrt(2*G*mass/radius);
System.out.println("Escape Velocity: "+ vescape+ " km/s");
}
}

Please suggest modifications to get the exact ans. as in the question.
I also think the last double vescape formula is getting me the wrong ans. so please help
View Answers

February 26, 2010 at 1:41 AM

Hi Abhishek Sisodia,

There is no flaw in your coding. Every thing is perfect.
Only mistake you are doing is giving the wrong i/p.

Here you are calculating escape velocity for planet Earth and you are performing all the calculations in km/s. But,you are giving Acceleration due to gravity 'g' in m/s.

Just give its value in km/s i.e 0.0098

You would get the answer you are expecting.

Just FYI,
These are the accurate values:
Circumference of Earth : 40,075.16 kms
Acceleration due to gravity (g) : 0.0098 km/s
Radius of the earth : 6,371 kms
Mass of the earth : 5.9742E24 kgs
G : 6.673006E-11
Escape Velocity of Earth : 11.1 km/s

Here are the links that I reffered:

http://geography.about.com/library/faq/blqzcircumference.htm
http://www.universetoday.com/guide-to-space/earth/radius-of-the-earth/
http://www.wonderquest.com/calculation-mass-of-earth.htm
http://www.wikihow.com/Calculate-Escape-Velocity
http://easycalculation.com/physics/classical-physics/learn-escape-velocity.php

It took me 4 hrs, to figure this out :)

Enjoy!

Regards,
javaquest2010.

February 26, 2010 at 7:31 AM

thank you very much javaquest









Related Tutorials/Questions & Answers:
java program7
program3 - Java Beginners
Advertisements
program1 - Java Beginners
program2 - Java Beginners
write a programm using java
java programe
java programm
menu drive programm in java
menu drive programm in java
java programe - Java Beginners
top 20 basic programm of java
ModuleNotFoundError: No module named 'programo'
ModuleNotFoundError: No module named 'programy'
java programe - Java Beginners
construction in java programm
programm
Programs in java
java programs
programs in java
Java Programs
ModuleNotFoundError: No module named 'program1'
java programs
java programe executing error - Java Beginners
java programs
java programs
java programs
java programs
java programs
java programs
java programs
java programs
Java Programs
Explain types of java programs
how to execuite java programs???
how to execuite java programs???
programs
Java programs - Java Beginners
A programm for error free transmission of data using UDP in java
Java programs - Java Beginners
Java programs on students assesment
3 Java Programs for Beginners
programm
Java Programs - Java Beginners
java programs - Java Beginners
java programs - Java Beginners
java programs - Java Beginners
java programs - Java Beginners
java programs - Java Beginners
java programs - Java Beginners
java programs - Java Beginners

Ads