# Lab 3
# YOUR NAMES HERE


# returns the absolute value of x:
# x, if x is positive or 0
# -x, if x is negative
# don't use the predefined abs() or math.abs() function!
def ABS(x):
  # your code here
  return None # REPLACE


# returns True when n is even
# returns False when n is odd
def isEven(n):
  # your code here
  return None # REPLACE


# returns True when n is odd
# returns False when n is even
def isOdd(n):
  # your code here
  return None # REPLACE


# return the maximum of a, b, c
# don't use the predefined max() function!
def max(a, b, c):
    # your code here
    return None # REPLACE


# return the minimum of a, b, c
# don't use the predefined min() function!
def min(a, b, c):
    # your code here
    return None # REPLACE


# returns True if (x,y) is inside the rectangle with corners (x1,y1) and (x2,y2)
# Assume x1 < x2 and y1 < y2
# Hint: use the and operator
def inRectangle(x, y, x1, y1, x2, y2):
  # your code here
  return None # REPLACE


# returns true if the year is a leap year:
# when a year is divisible by 4 (true), unless
# the year is divisible by 100 (false), unless
# the year is divisible by 400 (true)
# Leap years: 2000, 2020, 2024, 2028, etc
# Non-leap years: 2025, 2026, 2027, 1900, 2100, etc
# don't use any predefined date functions!
def isLeapYear(year):
  return None # REPLACE


# returns the number of days in a given numerical month (1-12) and year
#  1 (January) has 31 days
# 2 (February) >>>> 28 (normally) or 29 (leap year)
# 3 (March) >>>> 31
# 4 (April) >>>> 30
# 5 (May) >>>> 31
# 6 (June) >>>> 30
# 7 (July) >>>> 31
# 8 (August) >>>> 31
# 9 (September) >>>> 30
# 10 (October) >>>> 31
# 11 (November) >>>> 30
# 12 (December) >>>> 31
# Hint: Use the or operator and your isLeapYear() function
# don't use any predefined date functions!
def daysInMonth(month, year):
  return None # REPLACE


# compute the numeric day of the week, h, for a given date
# Use Zeller's algorithm to compute h:
# h = (q + (26(m+1))/10 + K + K/4 + J/4 + 5J) mod 7
# where all division is done as integer division
# q is the day of the month;
# m is the month (3 = March, 4 = April, 5 = May, ...).
#   January and February are considered the 13th and 14th months
#   of the previous year;
# K the year of the century (0, 1, ..., 99);
# J is the leading two digits of the year.
# h corresponds to the day, where
#   Saturday = 0, Sunday = 1, ..., and Friday = 6.
# For example, to compute the day of the week for January 6, 2021,
# q = 6, m = 13, K = 21, and J = 20; this will result in h = 4 (Wednesday). 
# don't use any predefined date functions!
def zeller(q, m, K, J):
    # your code here
    return None # REPLACE


# compute the numeric day of the week, h, for a given date
# compute q, m, K, and J from dd, mm, and yy
# use the day function above
# don't use any predefined date functions!
def day(dd, mm, yy):
    # your code here
    return None # REPLACE


# converts an integer code into a string representing the day of the week
# 0 is Saturday
# 1 is Sunday
# 2 is Monday
# 3 is Tuesday
# 4 is Wednesday
# 5 is Thursday
# 6 is Friday
# don't use any predefined date functions!
def dayName(day):
    # your code here
    return None # REPLACE


# converts an point percentage into a grade base on our syllabus
# https://mathcs.albion.edu/~dreimann/Spring2026/courses/cs171/
def grade(percentage):
    # your code here
    return None # REPLACE


# main function for testing
def main():
    print("Lab 2")
    
    print("ABS:")
    print(ABS(-10), "should be 10")
    print(ABS(10), "should be 10")
    print(ABS(0), "should be 0")
    
    print("isEven:")
    print(isEven(-2), "should be True")
    print(isEven(-1), "should be False")
    print(isEven(0), "should be True")
    print(isEven(1), "should be False")
    print(isEven(2), "should be True")
    
    print("isOdd:")
    print(isOdd(-2), "should be False")
    print(isOdd(-1), "should be True")
    print(isOdd(0), "should be False")
    print(isOdd(1), "should be True")
    print(isOdd(2), "should be False")
    
    print("Maximum:")
    print(max(1,2,3), "should be 3")
    print(max(1,3,2), "should be 3")
    print(max(2,1,3), "should be 3")
    print(max(2,3,1), "should be 3")
    print(max(3,1,2), "should be 3")
    print(max(3,2,1), "should be 3")
    
    print("Minimum:")
    print(min(1,2,3), "should be 1")
    print(min(1,3,2), "should be 1")
    print(min(2,1,3), "should be 1")
    print(min(2,3,1), "should be 1")
    print(min(3,1,2), "should be 1")
    print(min(3,2,1), "should be 1")
    
    print("inRectangle:")
    print(inRectangle(0,0, 10,20, 15,40), "should be False")
    print(inRectangle(15,0, 10,20, 15,40), "should be False")
    print(inRectangle(25,0, 10,20, 15,40), "should be False")
    print(inRectangle(0,30, 10,20, 15,40), "should be False")
    print(inRectangle(15,30, 10,20, 15,40), "should be True")
    print(inRectangle(25,30, 10,20, 15,40), "should be False")
    print(inRectangle(0,50, 10,20, 15,40), "should be False")
    print(inRectangle(15,50, 10,20, 15,40), "should be False")
    print(inRectangle(25,50, 10,20, 15,40), "should be False")

    print("isLeapYear")
    print(isLeapYear(2000), "should be True")
    print(isLeapYear(1900), "should be False")
    print(isLeapYear(2020), "should be True")
    print(isLeapYear(2021), "should be False")

    print("daysInMonth")
    print(daysInMonth(2, 2000), "should be 29")
    print(daysInMonth(2, 1900), "should be 28")
    print(daysInMonth(9, 2021), "should be 30")
    print(daysInMonth(10, 2021), "should be 31")
    
    print("Zeller")
    print(zeller(7, 9, 21, 20), "should be 3") # 9/7/2021
    print(zeller(1, 13, 21, 20), "should be 0") # 1/1/2022

    print("Day")
    print(day(7, 9, 2021), "should be 3") # 9/7/2021
    print(day(1, 1, 2022), "should be 0") # 1/1/2022

    print("Day Names:")
    print(dayName(-1), "should be ERROR")
    print(dayName(0), "should be Saturday")
    print(dayName(1), "should be Sunday")
    print(dayName(2), "should be Monday")
    print(dayName(3), "should be Tuesday")
    print(dayName(4), "should be Wednesday")
    print(dayName(5), "should be Thursday")
    print(dayName(6), "should be Friday")
    print(dayName(day(7, 9, 2021)), "should be Tuesday") # 9/7/2021
    print(dayName(day(1, 1, 2022)), "should be Saturday") # 1/1/2022

    print("grade")
    print(grade(93.5), "should be a 4.0")
    print(grade(73.5), "should be a 2.0")
    print(grade(37.9), "should be a 0.0")
    

# call the main function
main()
