Imports System Imports System.Globalization Module SpaceTripCalculator Sub Main() Dim distance As Double Dim speedFraction As Double Console.WriteLine("Space Trip Time Dilation Calculator") Console.WriteLine("-----------------------------------") ' Input distance to the destination (in light years) While True Console.Write("Enter the distance to your destination (in light years): ") Dim inputDistance As String = Console.ReadLine() ' Replace comma with dot for decimal conversion inputDistance = inputDistance.Replace(",", ".") If Double.TryParse(inputDistance, NumberStyles.Float, CultureInfo.InvariantCulture, distance) Then Exit While Else Console.WriteLine("Invalid input. Please enter a numeric value.") End If End While ' Input speed as a fraction of the speed of light (e.g., 0.9 for 90% of the speed of light) While True Console.Write("Enter your speed as a fraction of the speed of light (0 - 1): ") Dim inputSpeed As String = Console.ReadLine() ' Replace comma with dot for decimal conversion inputSpeed = inputSpeed.Replace(",", ".") If Double.TryParse(inputSpeed, NumberStyles.Float, CultureInfo.InvariantCulture, speedFraction) AndAlso speedFraction >= 0 AndAlso speedFraction < 1 Then Exit While Else Console.WriteLine("Invalid input. Please enter a numeric value between 0 and 1 (exclusive).") End If End While ' Calculate the time taken (time from observer's perspective) Dim speedOfLight As Double = 1.0 ' Speed of light in light years per year (for simplicity) Dim travelTimeObserver As Double = distance / speedFraction ' Calculate time dilation Dim timeDilationFactor As Double = 1.0 / Math.Sqrt(1 - speedFraction * speedFraction) Dim travelTimeTraveler As Double = travelTimeObserver / timeDilationFactor ' Output results Console.WriteLine($"Travel time for observer: {travelTimeObserver:F2} years") Console.WriteLine($"Travel time experienced by traveler: {travelTimeTraveler:F2} years") ' Wait for user to close the console Console.WriteLine("Press any key to exit...") Console.ReadKey() End Sub End Module