[Solved] Find what day in the month it is using day number Java


In a very basic approach, create an int array containing the number of days in each month.

final int[] daysInMonth = new int[] { 31, 28, 31, 30, ... };

Then check if it is a leap year, do:

daysInMonth[1]++;  // add an extra day in February

Create an int variable (called remainingDays) that initially will contain your input.
And your code should loop through the created array, first checking if the remainingDays - daysInMonth[i] (the numbers of days in the month) is greater than zero. If it is, then subtract the number of days of that month from the remainder of days and go to the next month. if it is not, then your answer is in the remainingDays variable.

(as you asked a walkthrough not the code that answers that)

1

solved Find what day in the month it is using day number Java