Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hello, Who can help me with this? Project: The MyInteger Class Problem is same as we have done in class. Problem Description: Design a class
Hello, Who can help me with this?
Project: The MyInteger Class
Problem is same as we have done in class.
Problem Description:
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 isEven(), isOdd(), and isPrime() that return true if the value is even, odd, or prime, respectively.
- Static methods isEven(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
}
Submit your MyInteger.java file
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