Java Please

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Java Please

Post by answerhappygod »

Java Please
Java Please 1
Java Please 1 (265.43 KiB) Viewed 8 times
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 }
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply