Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Lab Description Write a number class that can be used to test numbers for odd, even, and perfect. Sample Data Files Needed Number.java NumberRunner.ava 28
Lab Description Write a number class that can be used to test numbers for odd, even, and perfect. Sample Data Files Needed Number.java NumberRunner.ava 28 496 199 201 17 Sample Output 7 is odd 7 is not perfect ODD/EVEN NUMBERS ODD - any number when divided by 2 that has a remainder that is not 0 28 1s not odd 28 is perfect EVEN any number when divided by 2 that has a remainder of 0 496 1s not odd 496 1s perfect %-modulus-used to find the remainder of division 1111 is not perfect 199 1s odd 199 is not perfect PERFECT NUMBERS 201 is odd 201 is not perfect A perfect number is any number equal o the sum of its divisors 17 1s odd 17 is not perfect is perfect because it is equal to the sun of its divisors The divisors of are 1 2 3 public class Number private Integer number; public Number () public Number(int num) public void setNumber(int num) public int getNumber () return 0 public boolean isodd) return false: public boolean isPerfect int total-0 return (numbertotal); public String tostring() return import static java.lang.System.* public class NumberRunner public static void main(String[] args) int[] nums - 7,28,496,1111,199,201,17; for( int num ; nums) Number one - new Number ( num out.println one.isodd () ? one +" is odd. In" one "is not odd.In" out.println( one.isPerfect() one"is perfect.In": one"is not perfect.In
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