Question: Help in creating JAVA project by inserting the answers in the methods import java.util.ArrayList; import java.util.Scanner; public class CalendarPrinter { /** * Calculates the number

Help in creating JAVA project by inserting the answers in the methods

import java.util.ArrayList;

import java.util.Scanner;

public class CalendarPrinter {

/**

* Calculates the number of centuries (rounded down) between year 0 and the

* specified year. For example, the year 2034 has the century index of 20 (as do

* the other years 2000-2099).

* @param year to compute the century offset for

* @return number of centuries between year 0 and the specified year

*/

public static int fullCenturiesContained(Year year) {

}

/**

* Calculates the number of years between the specified year and the first year of

* its century. For example, the year 2034 has the offset within its century of 34

* (as do 1234 and 9999934).

* @param year to compute the offset within century for

* @return number of years between the specified year and the first year of century

*/

public static int yearOffsetWithinCentury(Year year) {

}

/**

* This method computes whether the specified year is a leap year or not.

* @param year is the year is being checked for leap-year-ness

* @return true when the specified year is a leap year, and false otherwise

*/

public static boolean isLeapYear(Year year) {

}

/**

* Calculates the number of days in the specified month, while taking into

* consideration whether or not the specified month is in a leap year.

* Note: that this is calculated based on the month's monthOfYear and year, and

* is NOT retrieved from the month's getDayCount() method. This is because this

* method is used to generate the day objects that are stored within each month.

* @param month to determine the number of days within (within its year)

* @return the number of days in the specified month (between 28-31)

*/

public static int numberOfDaysInMonth(Month month) {

}

/**

* Calculates which day of the week the first day of the specified month falls on.

* Note: that this is calculated based on the month's monthOfYear and year, and

* is NOT retrieved from the month's getDayByDate(1) day. This is because this

* method is used to generate the day objects that are stored within each month.

* @param month within which we are calculate the day of week for the first day

* @return DayOfWeek corresponding to the first day within the specified month

*/

public static DayOfWeek calcFirstDayOfWeekInMonth(Month month) {

}

/**

* Calculates the day of the week that follows the specified day of week.

* For example, Thursday comes after Wednesday, and Monday comes after Sunday.

* @param dayBefore is the day of week that comes before the day of week returned

* @return day of week that comes after dayBefore

*/

public static DayOfWeek dayOfWeekAfter(DayOfWeek dayBefore) {

}

/**

* Calculates the month of the year that follows the specified month. For example,

* July comes after June, and January comes after December.

* @param monthBefore is the month that comes before the month that is returned

* @return month of year that comes after monthBefore

*/

public static MonthOfYear monthOfYearAfter(MonthOfYear monthBefore) {

}

/**

* Creates a new month object and fully initializes with its corresponding days.

* @param monthOfYear which month of the year this new month represents

* @param year in which this month is a part

* @return reference to the newly created month object

*/

public static Month createNewMonth(MonthOfYear monthOfYear, Year year) {

}

/**

* Prints the contents of the specified month object in calendar form. This

* printout should begin with the Month an year of the month. The next line should

* contain the three letter abbreviations for the seven days of the week. And then

* the dates of each day of that month should follow: one week per line, with

* periods in positions of days that are a part of the month before or after. For

* example, January 2020 should be printed as follows:

*

* January 2020

* MON TUE WED THU FRI SAT SUN

* . . 1 2 3 4 5

* 6 7 8 9 10 11 12

* 13 14 15 16 17 18 19

* 20 21 22 23 24 25 26

* 27 28 29 30 31 . .

*

* @param month which is to be printed by this method

*/

public static void printMonth(Month month)

/**

* Creates an array list of months that are initialized with their full complement

* of days. Prints out each of these months in calendar form, and then returns the

* resulting ArrayList.

* @param month of the year for the first month that is created and printed

* @param year that the first month created and printed is a part of

* @param count is the total number of sequential months created and printed

*/

public static ArrayList createAndPrintMonths(MonthOfYear month,

Year year, int count)

To use and further test your implementations for the above methods, we are providing the following

main method for your CalendarPrinter class.

/**

* Driver for the CalendarPrinter Application. This program asks the user to enter

* an initial month, an initial year, and the total number of months to create and

* display in calendar form.

* @param args is not used by this program

*/

public static void main(String [] args) {

// print welcome message

Scanner in = new Scanner(System.in);

System.out.println("Welcome to the Calendar Printer.");

System.out.println("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~");

// read input from the user

System.out.print("Enter the month to begin calendar: ");

String monthString = in.nextLine().trim();

System.out.print("Enter the year to begin calendar: ");

String yearString = in.nextLine().trim();

System.out.print("Enter the number of months to include in this calendar: ");

String countString = in.nextLine().trim();

// convert user input into usable form

monthString = monthString.substring(0,3).toUpperCase();

MonthOfYear month = null;

for(int i=0;i<MonthOfYear.values().length;i++)

if(monthString.equals(MonthOfYear.values()[i].name().substring(0,3).toUpperCase()))

month = MonthOfYear.values()[i];

Year year = new Year(Integer.parseInt(yearString.trim()));

int count = Integer.parseInt(countString.trim());

// create months and display them in calendar form

System.out.println();

createAndPrintMonths(month,year,count);

// display thank you message

System.out.println("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~");

System.out.println("Thanks, and have a nice day.");

in.close();

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!