5.15 Even/Odd Counter - Java

in #programming9 years ago

  1. Even/Odd Counter

You can use the following logic to determine whether a number is even or odd:

if ((number % 2) == 0)
{
// The number is even.
}
else
{
// The number is odd.
}

Write a program with a method named isEven that accepts an int argument. The method should return true if the argument is even, or false otherwise. The program’s main method should use a loop to generate 100 random integers. It should use the
isEven method to determine whether each random number is even, or odd. When the loop is finished, the program should display the number of even numbers that were generated, and the number of odd numbers.

Gaddis, Tony (2015-05-29). Starting Out with Java: From Control Structures through Objects (Page 316). Pearson Education. Kindle Edition.

Happy Steeming Everyone! :)

Coin Marketplace

STEEM 0.04
TRX 0.32
JST 0.082
BTC 61674.69
ETH 1647.32
USDT 1.00
SBD 0.42