Answer to Question #188168 in Visual Basic for Abby

Question #188168

write a program that accepts dates written in numerical form and then output them as a complete form. for example, the input 2 26 1986 should produce the output: february 26, 1986


1
Expert's answer
2021-05-02T11:07:14-0400
Module Module1


    Sub Main()
        Dim months() = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}
        Dim day As Integer
        Dim monthIndex As Integer
        Dim year As Integer


        Console.Write("Enter the date in numerical form (Example: 2 26 1986): ")
        Dim inputValues() As String = Console.ReadLine().Split(" ")
        monthIndex = Integer.Parse(inputValues(0))
        If (monthIndex >= 0 And monthIndex < months.Length) Then
            day = Integer.Parse(inputValues(1))
            year = Integer.Parse(inputValues(2))
            Console.WriteLine("{0} {1}, {2}", months(monthIndex - 1), day, year)
        Else
            Console.WriteLine("Wrong month")
        End If
        Console.ReadLine()
    End Sub


End Module

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS