## Calculate the date for thanksgiving for any given year

Im writing a program that prints a 12 month calendar for any given year. I have completed that part of the code. However i still am required to write a method that will calculate and print the exact date that thanksgiving will fall on for that given year. I am required to use switch statements.

Im working on a code that prints the calendar for any given year after the year 1800. I have finished this part of the code, it is properly compiling and in fact prints out the entire 12 month calendar for any year inputted by the user. Another part of my assignment is to be able to print out the date for thanksgiving for any particular year that is inputted by the user. I am required to use a switch statement to create this method. The method I require help on is called "thanks" and I have highlighted it blue so it is easy to find. is what needs to be able to calculate the date and then print it.

Code:
```import java.util.Scanner;
public class PrintCalenderShell
{
public static void main(String[] args)
{
Scanner kb = new Scanner(System.in);
//prompt the user to enter the year
boolean repeat = true;
while (repeat)//repeat as long as the user wants to
{
int year =0;
//loop as long as the user is entering an invalid year less than 1800
while(year <1800)
{
System.out.println("Enter a valid year after 1800");
//loop as long as the user is entering an input other than integer
while (!kb.hasNextInt())
{
System.out.println("Enter a valid year after 1800:");
kb.next();
}
year = kb.nextInt();
}
//printing the calender for each month of the year
for (int i =1; i<=12; i++)
{
//call the method printMonth with the parameters year and i
printMonth(year, i);

}
System.out.println("Do you have another year to print the calender:yes/no");
repeat = false;
}

}
//this method prints the body of the calender for the given month
public static void printMonth(int year, int month)
{
//call the method printTitle with the values year and month
printMonthTitle(year, month);
//call the method printMonthBody with the values year and month
printMonthBody(year, month);

}
//this method prints the title of the days in each week(sunday Mon Tues Wed Thur Fir Sat)
public static void printMonthTitle(int year, int month)
{
System.out.println("         " + getMonthName(month) + " " + year);
System.out.println("----------------------------");
System.out.println(" Sun Mon Tue Wed Thu Fri Sat");
}
//this method outputs the calender for each month of the year
public static void printMonthBody(int year, int month)
{
//call the method getStartDay to get the start day for each month of the year
int startDay = getStartDay(year, month);
print(startDay, year, month);
//call the method print to print the calender for the month and pass the first day of the month as the parameter
}

public static void print(int startDay, int year, int month)
{
int start = getStartDay(year, month);
// call the method getNumberOfdaysInMonth to finde out the number of the days in the month
int numOfDaysInMonth = getNumberOfDaysInMonth(year, month);
for(int i=0; i<start; i++)
{
System.out.print("    ");
}
//use a for loop to print spaces up to the start day for each month
for(int i=1; i<=numOfDaysInMonth; i++)
{
System.out.printf("%4d", i);

//use another for loop to print the rest of the days in the calender
if((i+start)%7 ==0)
{
System.out.println();
}
}
System.out.println();

//if the month is November calculate the thanksgiving day and output            }
}

//this method calculates the date for thanksgiving, you need to use
//a switch statment
public static int thanks(int startDay)
{
//int thanks =(11-startDay)%7+22)

return 0;
}

public static String getMonthName(int month)
{
String monthName = "";
switch(month){
case 1: monthName = "January"; break;
case 2: monthName = "February"; break;
case 3: monthName = "March"; break;
case 4: monthName = "April"; break;
case 5: monthName = "May"; break;
case 6: monthName = "June"; break;
case 7: monthName = "July"; break;
case 8: monthName = "Aubuest"; break;
case 9: monthName = "September"; break;
case 10: monthName = "October"; break;
case 11: monthName = "November"; break;
case 12: monthName = "December"; break;
}
return monthName;
}

//this method returns the start day of the month
public static int getStartDay(int year, int month)
{
//call the method getTotalNumberOfDays and store it in a variable called start
int start = getTotalNumberOfDays(year, month);
start= start+3;
//add 3 to the variable start
return start%7;

}
//returns the total number of the days up to the given month in the given year
public static int getTotalNumberOfDays(int year, int month)
{
int sum = 0;
//for loop goes from 1800 up to the year
for(int i=1800; i<=year; i++)
{
if(isLeapYear(i))
{
sum = sum+366;
}else{
sum = sum+365;
}
}
//add number of days in the year to sum, call the method leapyear
for(int i=1; i<month; i++)
{
sum = sum+getNumberOfDaysInMonth(year, i);
}
return sum;
}

//use this method from the last HW
public static int getNumberOfDaysInMonth(int year, int month)
{
int days = 0;
switch(month)
{
case 1: days = 30;
break;
case 2: if(isLeapYear(year)){
days = 29;
}else{
days = 28;
}break;
case 3: days = 31;
break;
case 4: days = 30;
break;
case 5: days = 31;
break;
case 6: days = 30;
break;
case 7: days = 31;
break;
case 8: days = 31;
break;
case 9: days = 30;
break;
case 10: days = 31;
break;
case 11: days = 30;
break;
case 12: days = 31;
break;

}
return days;
}

public static boolean isLeapYear(int year)
{
return(year %400==0 || year%4==0 && year%100!=0);

}
}```