# Function to determine the starting day of a given year get_starting_day <- function(year) { if (!is.numeric(year) || year <= 0 || year != floor(year)) { return("Please enter a valid positive integer for the year.") } # Create a date object for January 1st of the given year start_date <- as.Date(paste(year, "-01-01", sep = "")) # Get the weekday name of the date starting_day <- weekdays(start_date) return(paste("The starting day of the year", year, "is", starting_day, ".")) } # Accept user input cat("Enter a year: ") input_year <- as.numeric(readline()) # Determine and display the starting day result <- get_starting_day(input_year) cat(result, "\n")