I'm working on a project and one of the things I need to do is create a method where it takes in an int array and checks it to see if it has more even than odds. The method needs to be boolean and take in an int[]
I know I need to use a for statement with something like
for (int i = 0; i < hasMoreEvenThanOdd.length; i++) or
for (int values : hasMoreEvenThanOdd) But I'm confused on what the for loop would contain something like this?
if (numerator % denomEven == 0) { boolean res = true; return res; } else if (numerator % denomOdd == 0) { boolean res = true; return res; } else { boolean res = false; return res; } and I'm not sure how to get the math to check out in the end.
https://stackoverflow.com/questions/66125521/how-do-you-check-an-array-to-see-if-it-has-more-even-values-than-odd February 10, 2021 at 03:09AM
没有评论:
发表评论