Skip to content

mtaseva/A-small-Java-code-snippet-from-University-assignment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“˜ README (in English) πŸ‡¬πŸ‡§

πŸ“˜ This README is also available in Macedonian: README.mk.md

Gravitational Acceleration Calculator in Java

πŸ“Œ Description

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.

πŸ§ͺ Formula Used

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 height h

πŸš€ How to Run

  1. Make sure you have Java installed on your system.
  2. Save the code in a file named Gravitacija.java.
  3. Open a terminal and compile the program: javac Gravitacija.java
  4. Run the compiled class: java Gravitacija
  5. Enter the height when prompted (e.g., 0, 1000, 1000000).

πŸ“„ Example Output

Vnesete visina (v metrih)

1000000

Pospesek je enak: 7.337700 m/s^2

Visina je enaka: 1000000 m

πŸ‘€ Author

This project was created for educational purposes by Marija Taseva.

About

Code snippet for gravitation calculations

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages