• Post Reply Bookmark Topic Watch Topic
  • New Topic

Exercise from Java in 21 days (newest edition covering Java 8)  RSS feed

 
Naziru Gelajo
Ranch Hand
Posts: 175
1
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I am working on an Exercise from Java in 21 days (I'm currently working on Day 4). and I was looking at an exercise:

So Using this method :


I'm supposed to display all the days from January 1 - December 31 (so it should look like January 1, January 2, January 3, etc. etc. on a separate line) until it reaches December 31st. However, with the code i have written thus far, I can only get it to display the last day of each month of a particular year (I happened to choose 2016. I'm very disappointed with my problem solving skills thus far. I thought that this would be a walk in the park, but I'm struggling and it's infuriating me. Surely, I shouldn't be having this much difficulty with using premade methods and implementing them into the main class. In any case, here's my code. Please help me dissect what's wrong with how I'm approaching the problem.



The method is not my method. But I"m supposed to utilize it to do the aforementioned. Thanks!
 
Paweł Baczyński
Bartender
Posts: 2076
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make a method that displays all days in a single month (takes number of the month and a year as parameters).
Inside the method loop from 1 to whatever countDays returned.
 
Naziru Gelajo
Ranch Hand
Posts: 175
1
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paweł Baczyński wrote:Make a method that displays all days in a single month (takes number of the month and a year as parameters).
Inside the method loop from 1 to whatever countDays returned.


Isn't that what the countDay's method kind of does. Its parameters are month and year. There are cases for each month.
 
Paweł Baczyński
Bartender
Posts: 2076
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This method only returns how many days a month has. You need to write printing logic yourself.
 
Naziru Gelajo
Ranch Hand
Posts: 175
1
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paweł Baczyński wrote:This method only returns how many days a month has. You need to write printing logic yourself.


Oh ok got it, thanks! I hate how I'm so bad at Java right now. I seem to be having trouble being good at for loops and understanding that i need to edit the method. Please tell me that it gets better.
 
Paweł Baczyński
Bartender
Posts: 2076
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course it gets better! That is the way you learn. :-D
 
Naziru Gelajo
Ranch Hand
Posts: 175
1
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paweł Baczyński wrote:Of course it gets better! That is the way you learn. :-D


Thanks man your words are really encouraging. My ultimate goal is to become a great Android developer and also pass the OCA/OCP exam. Thanks so much for the encouraging words brother.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!