Question: How would I type part 2 so it has the same output as part 1? part1.) private static int calDayInYear(int month, int day) { int
How would I type part 2 so it has the same output as part 1?
part1.)
private static int calDayInYear(int month, int day) { int DayOfMonth [] = {31,28,31,30,31,30,31,31,30,31,30,31}; int calDay = 0; public static void
for(int i=0; i < month-1; i++){ calDay = calDay + month; } return calDay+day; }
Part 2.)
public static int calDayInYear(int month, int days){ if (month == 2){ return 28; //28 days }else if (month == 4 || month == 6 || month == 9 || month == 11){ return 30; //30 days }else{ return 31; //31 days } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
