Question: CSC 1351-02, Spring 2023, Lab 3 Name this project EasterDate Create a project named EasterDate. NetBeans will create a class with the same name, EasterDate.






CSC 1351-02, Spring 2023, Lab 3 Name this project EasterDate Create a project named EasterDate. NetBeans will create a class with the same name, EasterDate. The EasterDate class that NetBeans creates will have a main method in it but will not be the main class. Delete the main method that NetBeans puts in the EasterDate class and implement the EasterDate class as described below. Then create another class named EasterDateDemo which will be the main class. It will contain the main method. Implement the EasterDateDemo class as described below. You will need to call the getMonth method and the getWeekDay method from the main method in order to get the month and the day of the week for the printouts. The EasterDate Class The EasterDate class should have month, day and year, all integers, as instance variables. The EasterDate class should have the following methods: public String getMonth() //returns the name of the month as a string (does not return the instance variable month) public int getDay() // returns the instance variable day public int getYear() // returns the instance variable year public void setYear(int y) // sets the instance variable year to the input parameter y public void setMonthAndDay(int m, int d) // sets the instance variables month and day to the input parameters m and d public String getWeekDay() // Calculates the day of the week and returns it as a string public int[] getEasterMonthAndDay() // Calculates the month and day of Easter as integers and returns these two integers in an int array The EasterDateDemo Class The EasterDateDemo class should do the following: 1) Prompt the user for a year. 2) Read the year. 3) Construct an object of the EasterDate class. 4) Call the setYear nethod to set the instance variable year to the input year. 5) Call the getEasterMonthAndDay method to get the month and day of Easter in an int array. 6) Call the setMonthAndDay method to set the instance variables month and day to the values that were returned by the getEasterMonthAndDay method. 7) Call the getWeekday method to get the day of the week of Easter as a string. 8) Call the getMonth method to get the month of Easter as a string. 9) Print the date of Easter as shown in the output. In order to determine the weekday on which a day falls, use the following algorithm: 1. u=2(3 - (century mod 4) ), where century is the first two digits of the year. For example, century is 20 for the year 2011. 2. v= the last two digits of the year. For example, v is 11 for 2011 . 3. w=4E, using integer division. For example, =11/4=2 for 2011 . 4. x is determined using the month Table 1. For example, x is 3 for February 2011. Table 1: Month x There are two ways in which a year may be a leap year. Definition 1. Any year that is either a multiple of 400 or is not a multiple of 100 , but is a multiple of 4 is a leap year. 5. y=u+v+w+x+ day. y=6+11+2+3+3=25 for February 3,2011 . 6. day of the week =y mod 7. For example, February 3,2011 occurs on Thursday, since 25 mod7 is 4 . Note that 0= Sunday, 1= Monday, ... , 6 = Saturday. In order to determine the month and day of Easter as integers, use the following algorithm: In 1800 Carl Friedrick Gauss developed an algorithm to calculate the day that Easter falls on, for any given year: 1. Let y be the year (such as 1800 or 2001) 2. Get the remainder of y divided by 19 and call it a. 3. Get the integer part of y divided by 100 and call it b. 4. Get the remainder of y divided by 100 and call it c. 5. Get the integer part of b divided by 4 and call it d. 6. Get the remainder of b divided by 4 and call it e. 7. Get the integer part of (8b+13) divided by 25 and call it g. 8. Get the remainder of (19a+bdg+15) divided by 30 and call it h. 9. Get the integer part of c divided by 4 and call it j. 10. Get the remainder of c divided by 4 and call it k. 11. Get the integer part of (a+11h) divided by 319 and call it m. 12. Get the remainder of (2e+2jkh+m+32) divided by 7 and call it r. 13. Get the integer part of (hm+r+90) divided by 25 and call it n. 14. Get the remainder of (hm+r+n+19) divided by 32 and call it p. Then Easter falls on day p of month n. Additional Requirements All methods must be public and all instance variables private. Do not use if-statements to determine the name of the weekday or month: declare two arrays of strings, one with the names of the months and the other with the days of the week, and use the appropriate indexes to obtain them Here are five sample program runs: Sample Run 1 Enter a year: 1956 In 1956, Easter falls on Sunday, April 1 Enter a year: 1970 In 1970, Easter falls on Sunday, March 29 Sample Run 3 Enter a year: 2000 In 2000, Easter falls on Sunday, April 23 Sample Run 4 Enter a year: 2008 In 2008, Easter falls on Sunday, March 23 Sample Run 5 Enter a year: 2023 In 2023, Easter falls on Sunday, April 9
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
