Ask Question
26 March, 18:13

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.

+4
Answers (1)
  1. 26 March, 18:31
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers