Imports System.Globalization Module Module1 Sub Main() REM ROCKET.BAS by Brian Tung Dim A As Double = 1.032 REM Earth gravity in light-years per year squared Dim D As Double Do Console.WriteLine("Distance in light-years (0-100 million)") Double.TryParse(Console.ReadLine, D) If D >= 0 And D <= 100000000 Then Exit Do Else Console.WriteLine("Distance must be between 0 and 100 million l-y") End If Loop Dim D1 As Double = D / 2 Dim T As Double = Math.Sqrt(D1 * D1 + (2 * D1 / A)) Dim X As Double = A * T Dim M As Integer = 1 REM Lines 110-180 compute inverse sinh If X < 0 Then M = -1 Dim S As Double = Math.Log(Math.Abs(X) + 1) Dim S1 As Double = S + 1 Do Dim X1 As Double = (Math.Exp(S) - Math.Exp(-S)) / 2 - Math.Abs(X) S1 = X1 / (Math.Exp(S) + Math.Exp(-S)) / 2 S = S - S1 If Math.Abs(S1) <= 0.0000001 Then Exit Do Loop Dim T1 As Double = 1 / A * S * M Dim V As Double = A * T / Math.Sqrt(1 + (A * T) * (A * T)) Console.WriteLine("Time on Earth: {0} years", (2 * T).ToString("#########.###", CultureInfo.InvariantCulture)) Console.WriteLine("Time on board: {0} years", (2 * T1).ToString("#########.###", CultureInfo.InvariantCulture)) Dim Z As String = "Top speed: " Dim Z3 As String = "#.###" If D >= 1 Then Dim Z1 As Double = Int(2 * Math.Log(D) / Math.Log(10)) If D >= 1 And D < 10000000 Then Dim Z2 As Integer = Z1 Z3 = Z3 + StrDup(Z2, "#") End If If D >= 10000000 Then Z3 = Z3 + "#############" End If End If Z = Z + "{0} c" Console.WriteLine(Z, V.ToString(Z3, CultureInfo.InvariantCulture)) Console.WriteLine("Press any key to exit...") Console.ReadKey() REM APPEARED IN COMPUTERS IN REM ASTRONOMY, SKY & TELESCOPE, REM FEBRUARY 2002, PAGE 66 End Sub End Module