I am making a program to list every day in a year that the user inputs as a command line argument. Here's the relevant code:
class DisplayDays {
public static void main(String[] arguments) {
int yearIn = 2008; //default in case user doesn't enter a year
if (arguments.length > 0) //if user enters year, that's what we work with
yearIn = Integer.parseInt(arguments[0]);
For (int month = 1; month <= 12; month++) {
int daysInMonth = countDays(month, yearIn);
For (int dayOfMonth = 1; dayOfMonth <= daysInMonth; dayOfMonth++) {
System.out.println(month + "/" + dayOfMonth + "/" + yearIn);
}
}
}
//for each month, find the number of days in it
static int countDays(int month, int year) {
int count = -1;
switch (month) {
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
count = 31;
break;
case 4:
case 6:
case 9:
case 11:
count = 30;
break;
case 2:
if (year % 4 == 0)
count = 29;
else
count = 28;
if ((year % 100 == 0) & (year % 400 != 0))
count = 28;
}
return count;
}
}
When I tried to compile, there was an error on line 6, '.class' expected. What am I doing wrong??