forked from esp8266/Arduino
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTime Dilation
More file actions
20 lines (16 loc) · 897 Bytes
/
Time Dilation
File metadata and controls
20 lines (16 loc) · 897 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public class TimeDilation {
public static void main(String[] args) {
// Constants
double speedOfLight = 299792458.0; // Speed of light in meters per second
// Observer's velocity relative to the speed of light
double velocity = 0.9 * speedOfLight; // 90% of the speed of light
// Time experienced by a stationary observer (in seconds)
double stationaryTime = 60.0; // 60 seconds (1 minute)
// Calculate time dilation
double timeDilation = stationaryTime / Math.sqrt(1 - (velocity * velocity) / (speedOfLight * speedOfLight));
// Display the results
System.out.println("Observer's velocity: " + velocity + " m/s");
System.out.println("Stationary observer's time: " + stationaryTime + " seconds");
System.out.println("Time experienced by moving observer: " + timeDilation + " seconds");
}
}