Piet Souris wrote:A simple way without calculations is to have a 2D array month, where the first index is the month, and the second index the number of days in that month. So month = new int, month = new int[28/29], et cetera. Then loop through all the months and days, starting with day janFirst.
Fred Kleinschmidt wrote:Note that it is not necessary for the caller to specify what day January 1 is (not only that, it is just wrong to do so - the caller could easily enter the incorrect day).
Knowing that January 1, 2018 was a Monday, it is not too difficult to deduce what day January 1 is for any specified year.
It is also not necessary to include a parameter that specifies whether it is a leap year (that also allow the caller to make an error).
Swastik Dey wrote:Ok..then even things are getting complicated. You can use Calendar, class it would be much easier.
Swastik Dey wrote:What is the reason behind starting from January? Why not start from the 1st of the given month and year itself.
Swastik Dey wrote:One problem as per my understanding is your return statement is out side the loop, so it will print only when the loop terminates. You either need some sort of recursive function or the print statement should be inside the loop itself.
Carey Brown wrote:
Victoria Li wrote:I don't know exactly how to begin. How would I be able to get a user input for the empty and filled spaces in a 200x60 two-dimensional array?
Seems like entering (up to) 200x60 cells would be extremely tedious and error prone. You could instead read a file with the cell configuration. Perhaps something like:
You could have an option to fill in the cells with random booleans. The specs seem to leave it up to you.
Campbell Ritchie wrote:Why have you got all your class members static?
Have you been through the Java™ Tutorials, because I think you will find lots of useful information there?