Task

Write a program to perform a conversion of the old Russian measures of length to the metric system   (and vice versa).



It is an example of a linear transformation of several variables.



The program should accept a single value in a selected unit of measurement, and convert and return it to the other units:

vershoks, arshins, sazhens, versts, meters, centimeters and kilometers.



Also see

   Old Russian measure of length


' FB 1.05.0 Win64
 
Dim units(1 To 13) As String = {"tochka", "liniya", "dyuim", "vershok", "piad", "fut", _
                                "arshin", "sazhen", "versta", "milia", _
                                "centimeter", "meter", "kilometer"}
 
' all expressed in centimeters
Dim convs(1 To 13) As Single = {0.0254, 0.254, 2.54, 4.445, 17.78, 30.48, _
                                71.12, 213.36, 10668, 74676, _
                                1, 100, 10000}
Dim unit As Integer
Dim value As Single
Dim yn As String
 
Do
  Shell("cls")
  Print 
  For i As Integer = 1 To 13
    Print Using "##"; i;
    Print " "; units(i)
  Next
  Print
  Do
    Input "Please choose a unit 1 to 13 : "; unit
  Loop Until unit >= 1 AndAlso unit <= 13  
  Print
  Do
    Input "Now enter a value in that unit : "; value
  Loop Until value >= 0 
  Print
  Print "The equivalent in the remaining units is : "
  Print
  For i As Integer = 1 To 13
    If i = unit Then Continue For
    Print " "; units(i), " : "; value * convs(unit) / convs(i)
  Next
  Print
  Do
    Input "Do another one y/n : "; yn
    yn = LCase(yn)
  Loop Until yn = "y" OrElse yn = "n"
Loop Until yn = "n"
 
End