Java Please
Design a class named MyInteger. The class contains: • An int data field named value that stores the int value represented by this object. • A constructor that creates a MyInteger object for the specified int . A get method that returns the int • Methods is Even(), isOdd(), and isPrime() that return true if the value is even, odd, or prime, respectively. • Static methods is Even(int), isOdd(int), and isPrime(int) that return true if the specified value is even, odd, or prime, respectively. • Method equals(int) that return true if the value in the object is equal to the specified value. public class Exercise10_03 { public static void main(String[] args) { MyInteger n1 = new MyInteger(5); System.out.println("n1 is even? " + n1.isEven()); System.out.println("n1 is prime? " + n1.isPrime()); System.out.println("n1 is prime? " + n1.isOdd()); } class MyInteger { // Implement your class here }
Java Please
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am