Write a console application that prints the next 20 leap years. A leap year is a year in which an extra day is added to the Gregorian calendar, which is used by most of the world. While an ordinary year has 365 days, a leap year has 366 days. ... A leap year comes once every four years. Because of this, a leap year can always be evenly divided by four. [20 marks]
Module Module1
Sub Main()
'get the the current year
Console.Write("Enter the current year: ")
Dim currentYear As Integer = Integer.Parse(Console.ReadLine())
'prints the next 20 leap years
Console.WriteLine("The next 20 leap years are: ")
Dim leapCounter As Integer = 0
Do While leapCounter < 20
' A leap year comes once every four years. Because of this, a leap year can always be evenly divided by four
If (currentYear Mod 4 = 0) Then
Console.WriteLine("{0} is a leap year", currentYear.ToString())
leapCounter += 1
End If
currentYear += 1
Loop
Console.ReadLine()
End Sub
End Module
Comments
Leave a comment