• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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

 
Ranch Hand
Posts: 186
1
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Bartender
Posts: 2236
63
IntelliJ IDE Firefox Browser Spring Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 186
1
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2236
63
IntelliJ IDE Firefox Browser Spring Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 186
1
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2236
63
IntelliJ IDE Firefox Browser Spring Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Of course it gets better! That is the way you learn. :-D
 
Naziru Gelajo
Ranch Hand
Posts: 186
1
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
What's gotten into you? Could it be this tiny ad?
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic