RosettaCodeData/Task/Chinese-zodiac/Visual-Basic-.NET/chinese-zodiac.vb
2023-07-01 13:44:08 -04:00

31 lines
1.3 KiB
VB.net

Module Module1
ReadOnly ANIMALS As String() = {"Rat", "Ox", "Tiger", "Rabbit", "Dragon", "Snake", "Horse", "Goat", "Monkey", "Rooster", "Dog", "Pig"}
ReadOnly ELEMENTS As String() = {"Wood", "Fire", "Earth", "Metal", "Water"}
ReadOnly ANIMAL_CHARS As String() = {"", "", "", "", "", "", "", "", "", "", "", ""}
ReadOnly ELEMENT_CHARS As String(,) = {{"", "", "", "", ""}, {"", "", "", "", ""}}
Function GetYY(year As Integer) As String
If year Mod 2 = 0 Then
Return "yang"
End If
Return "yin"
End Function
Sub Main()
Console.OutputEncoding = System.Text.Encoding.UTF8
Dim years = {1935, 1938, 1968, 1972, 1976, 1984, 1985, 2017}
For i = 0 To years.Length - 1
Dim t0 = years(i)
Dim t1 = t0 - 4.0
Dim t2 = t1 Mod 10
Dim t3 = t2 / 2
Dim t4 = Math.Floor(t3)
Dim ei As Integer = Math.Floor(((years(i) - 4.0) Mod 10) / 2)
Dim ai = (years(i) - 4) Mod 12
Console.WriteLine("{0} is the year of the {1} {2} ({3}). {4}{5}", years(i), ELEMENTS(ei), ANIMALS(ai), GetYY(years(i)), ELEMENT_CHARS(years(i) Mod 2, ei), ANIMAL_CHARS((years(i) - 4) Mod 12))
Next
End Sub
End Module