π This README is also available in Macedonian: README.mk.md
This is a simple Java console program that calculates the gravitational acceleration (g) at a given height above the Earth's surface. The user is prompted to enter a height (in meters), and the program outputs the corresponding gravitational acceleration based on Newton's Law of Universal Gravitation.
The formula used in the program is:
g = (G * M) / (R + h)Β²
Where:
G= 6.674 Γ 10β»ΒΉΒΉ NΒ·mΒ²/kgΒ² (gravitational constant)M= 5.972 Γ 10Β²β΄ kg (mass of the Earth)R= 6.371 Γ 10βΆ m (radius of the Earth)h= height above Earth's surface (input from user)g= gravitational acceleration at heighth
- Make sure you have Java installed on your system.
- Save the code in a file named
Gravitacija.java. - Open a terminal and compile the program: javac Gravitacija.java
- Run the compiled class: java Gravitacija
- Enter the height when prompted (e.g.,
0,1000,1000000).
Vnesete visina (v metrih)
1000000
Pospesek je enak: 7.337700 m/s^2
Visina je enaka: 1000000 m
This project was created for educational purposes by Marija Taseva.