Question
In Java: Write a method isEven that uses the remainder operator (%) to determine whether an integer is even. The method should take an integer
In Java: 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.
Sample Run:
Enteranumber:0? 0iseven? Enterytoplayagain,ntoquit(y/n):y? ?Enteranumber:1? 1isodd? Enterytoplayagain,ntoquit(y/n):y? ?Enteranumber:-3? -3isodd? Enterytoplayagain,ntoquit(y/n):y? ?Enteranumber:-111? -111isodd? Enterytoplayagain,ntoquit(y/n):y? ?Enteranumber:-113? -113isodd? Enterytoplayagain,ntoquit(y/n):y? ?Enteranumber:-115? -115isodd? Enterytoplayagain,ntoquit(y/n):y? ?Enteranumber:-118? -118iseven? Enterytoplayagain,ntoquit(y/n):y? ?Enteranumber:202? 202iseven? Enterytoplayagain,ntoquit(y/n):y? ?Enteranumber:7? 7isodd? Enterytoplayagain,ntoquit(y/n):n? ??
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started