Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The current calendar, called the Gregorian calendar, was introduced in 1582. Eve

ID: 3653419 • Letter: T

Question

The current calendar, called the Gregorian calendar, was introduced in 1582. Every year divisible by four was declared to be a leap year, with the exception of the years ending in 00 (that is those divisible by 100) and not divisible by 400. For instance, the years 1600 and 2000 are leap years, but 1700, 1800, and 1900 are not. Write a program that requests a year as input and states whether it is a leap year. (Test the program on the years 2008, 2009, 1900, and 2000.)

Explanation / Answer

Public Function IsLeapYear(Year As Integer) As Integer 'Dim TorF for local variable to declare if the value is t/f. Dim TorF As Boolean 'Pre conditions: Year > 1581 and Year < 3000 If Year > 1581 And Year 1700 Or 1800 Or 1900 Then IsLeapYear = Year / 4 Else IsLeapYear = False TorF = False End If End Function Now here is my form (it's inaccurate too, but again, I'm working on a small level, just using simple pre/post conditions and If/Then/Else statements): Code: Private Sub cmdCalc_Click() txtYear = IsLeapYear(txtYear) If TorF = True Then lblSolution.Caption = "The year " & txtYear & " is a leap year." Else lblSolution.Caption = "This is not a leap year." End If End Sub
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote