Ask Question
16 October, 04:16

6.17 (Even or Odd) Write a method isEven that uses the remainder operator (%) to determine whether an integer is even. The method should take an integer argument and return true if the integer is even and false otherwise. Incorporate this method into an application that inputs a sequence of integers (one at a time) and determines whether each is even or odd.

+1
Answers (1)
  1. 16 October, 06:23
    0
    The % divides a number and returns the remainder.

    To determine if it's an even or odd number, do num%2

    if num%2 = = 0, then it's an even number because the number is divisible by 2, hence returned no remainder.

    if num%2! = 0, then it's an odd number.

    I don't use java so I don't know how to write it in Java, but in C it would look something like this:

    int even_odd (int num) {

    if (num%2 = = 0) return 1;

    else return 0;

    }
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “6.17 (Even or Odd) Write a method isEven that uses the remainder operator (%) to determine whether an integer is even. The method should ...” in 📙 Engineering if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers