+ 4

Help needed understanding the condition

I am trying to solve a problem. The condition is to write a function that takes a list of dates( a date being yyyy mm dd) and a month and returns how many dates in the list are in the given month. I am not sure if I understand correctly, but from a given list of dates, possibly from different years, to return the dates that are in the given month, which there is the possibility that there could be none. Correctly?

4th Mar 2017, 9:49 PM
Elena
Elena - avatar
9 Antworten
+ 10
Java8 using java.time: You could store a list of LocalDates and use getMonth method which returns an enum, then test it with some statement like if (localDate.getMonth() == Month.APRIL) ...
5th Mar 2017, 2:29 PM
Tashi N
Tashi N - avatar
+ 7
I mean a date having the form: 2017.03.05
5th Mar 2017, 11:42 AM
Elena
Elena - avatar
+ 5
@luka, I have a list of dates (yyyy, mm,dd) and a month. I need to return the number of times the dates from the list are in the given month.
5th Mar 2017, 11:27 AM
Elena
Elena - avatar
+ 4
Create a counter variable, loop through the list of dates. While looping increase the counter when you find dates with required month. Return the counter variable as result.
4th Mar 2017, 10:00 PM
Ivan G
Ivan G - avatar
+ 4
int counter=0; for(date:dates[]){if(date.toString().contains("month"))counter++;} or check ? and * in Your lang.
5th Mar 2017, 12:42 PM
Michał Bujakowski
Michał Bujakowski - avatar
+ 1
if(logical conclusion mean true or false true and false not true and not false .... all hypotheses of boolean){ then here action implemented therefore the hypotheses t o f and so on... }
6th Mar 2017, 3:08 PM
MØhåmměď EŁāmįń
MØhåmměď EŁāmįń - avatar
+ 1
conditions is choices operating if one choice done then the other get of for example if i had choice to go to market include 2 waies if way 1 short do ...go with it else go with other int way1=55; int way2=66; if(way1>way2){ System.out.println("my choice"); }else System.out.println(" not my choice use other")
11th May 2017, 5:34 PM
MØhåmměď EŁāmįń
MØhåmměď EŁāmįń - avatar
+ 1
int getCount(array a, query q){ int count=0; for each q{ if (a.contains(q)) count+1; } return count; } in Your case a.contains will be named i.e. 'getMonth()' Guys, these are essential logic operations - i see no danger for me as a hypothetic concurrent idea's author , facing others problems on such a trivial level. So stand questioned problems are significant for those who are lazy or wrong-way-turned. My advice - look for other ways to earn money becouse You will just spoil and litter the market...
12th May 2017, 2:26 AM
Michał Bujakowski
Michał Bujakowski - avatar