Question
According to the following code apply: 1. PC 2. CC 3. CoC 4. GACC 3 public class PrintCalendar { 4 /** Main method */ 5
According to the following code apply: 1. PC 2. CC 3. CoC 4. GACC 3 public class PrintCalendar { 4 /** Main method */ 5 public static void main(String[] args) { 6 Scanner input = new Scanner(System.in); 7 8 // Prompt the user to enter year 9 System.out.print("Enter full year (e.g., 2001): "); 10 int year = input.nextInt(); 11 12 // Prompt the user to enter month 13 System.out.print("Enter month in number between 1 and 12: "); 14 int month = input.nextInt(); 15 16 // Print calendar for the month of the year 17 printMonth(year, month); 18 } 19 20 /** Print the calendar for a month in a year */ 21 public static void printMonth(int year, int month) { 22 // Print the headings of the calendar 23 printMonthTitle(year, month); 24 25 // Print the body of the calendar 26 printMonthBody(year, month); 27 } 28 29 /** Print the month title, e.g., May, 1999 */ 30 public static void printMonthTitle(int year, int month) { 31 System.out.println(" " + getMonthName(month) 32 + " " + year); 33 System.out.println("-----------------------------"); 34 System.out.println(" Sun Mon Tue Wed Thu Fri Sat"); 35 } 36 37 /** Get the English name for the month */ 38 public static String getMonthName(int month) { 39 String monthName = ""; 40 switch (month) { 41 case 1: monthName = "January"; break; 42 case 2: monthName = "February"; break; 43 case 3: monthName = "March"; break; 44 case 4: monthName = "April"; break; 45 case 5: monthName = "May"; break; 46 case 6: monthName = "June"; break; 47 case 7: monthName = "July"; break; 48 case 8: monthName = "August"; break; 49 case 9: monthName = "September"; break; 50 case 10: monthName = "October"; break; 51 case 11: monthName = "November"; break; 52 case 12: monthName = "December"; 53 } 54 55 return monthName; 56 } 57 58 /** Print month body */ 59 public static void printMonthBody(int year, int month) { 60 // Get start day of the week for the first date in the month 61 int startDay = getStartDay(year, month); 62 63 // Get number of days in the month 64 int numberOfDaysInMonth = getNumberOfDaysInMonth(year, month); 65 66 // Pad space before the first day of the month 67 int i = 0; 68 for (i = 0; i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started