x.Hmprogram prints a calendar for the year 2000. My problem is that l am suppose
ID: 3615083 • Letter: X
Question
x.Hmprogram prints a calendar for the year 2000. My problem is that l am supposed to print the calendar in two columns but it is printing in one column. How can l print it with one column from January to June and the other July to December.import javax.swing.*;
public class Calendar
{
public static void main (String [] args)
{
int year = 2000;
System.out.println(year);
for(int i=1;i<=12;i++){
monthCalendar(year, i);
}
}
/** Determine if it is a leap year */
public static boolean isLeapYear(int year)
{
if ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0)))
return true;
else
return false;
}
/** Get the number of days in a month */
public static int daysInMonth(int year, int month)
{
if (month == 1 || month==3 || month == 5 || month == 7 ||
month == 8 || month == 10 || month == 12)
return 31;
if (month == 4 || month == 6 || month == 9 || month == 11)
return 30;
if (month == 2)
if (isLeapYear(year))
return 29;
else
return 28;
return 0;
}
/** Get the month */
public static String getMonthName(int month) {
String monthName = null;
if (month==1)
{
monthName="January";
}
else if (month==2)
{
monthName="Februrary";
}
else if (month==3)
{
monthName="March";
}
else if (month==4)
{
monthName="April";
}
else if (month==5)
{
monthName="May";
}
else if (month==6)
{
monthName="June";
}
else if (month==7)
{
monthName="July";
}
else if (month==8)
{
monthName="August";
}
else if (month==9)
{
monthName="September";
}
else if (month==10)
&
Explanation / Answer
x.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.