Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(the MyInteger class) design a class named MyInteger. the class contains: an int

ID: 3768865 • Letter: #

Question

(the MyInteger class) 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 value. a getter method that returns the int value.

the methods isEven(int), isOdd(), and isPrime() that return true if the valuein this object is even, odd, or prime, respectively.

the static methods isEven(MyInteger), isOdd(MyInteger) and isPrime(MyInteger) that return true if the specified value is even, odd, or prime respectively.

the methods equals(int) and equals(MyInteger) and that return true if the value in this object is equal to the specified value.

a static method parseInt(char[]) that converts an array to numberic characters to an int vlalue.

A static method parseInt(String) that converts a string into an int value.

a static method parseInt(String) that converts a string into an int value.

draw the UML diagram for the class and then implement te class. write a client program that tests all theods in the class. given that the definitin of a prime number is a postive integer be sure to instruct the user to only enter postive integers.

Explanation / Answer

import javax.swing.JOptionPane;

public class MyInteger{

    private int value;

     

    public MyInteger()

    {

        value = JOptionPane.showInputDialog("Enter the number ");

        int number = Integer.parseInt(value);

    }

    public MyInteger(int initialNumber)

    {

        number = initialNumber;

    }

    public int isEven()

    {

        if (number % 2 = 0)

        {

            return number;

        }

        else

        {

            System.out.println("Not an even digit");

        }

    }

    public int isOdd()

    {

        if (number % 2 != 0)

        {

            return number;

        }

        else

        {

            System.out.println("not an odd digit");

        }

    }

    public int isPrime()

    {

         

}