Question: public class Exercise10_3_addClass { 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?

 public class Exercise10_3_addClass { public static void main(String[] args) { MyInteger

public class Exercise10_3_addClass { 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("15 is prime? " + MyInteger.isPrime(15)); char[] chars = {'3', '5', '3', '9'}; System.out.println(MyInteger.parseInt(chars)); String s = "3539"; System.out.println(MyInteger.parseInt(s)); MyInteger n2 = new MyInteger(24); System.out.println("n2 is odd? " + n2.isOdd()); System.out.println("45 is odd? " + MyInteger.isOdd(45)); System.out.println("n1 is equal to n2? " + n1.equals(n2)); System.out.println("n1 is equal to 5? " + n1.equals(5)); } } // add the class MyInteger { // isPrime() { // boolean isEven() { // public static boolean isEven(MyInteger n) { // public static int parseInt(char[] numbers) { // numbers consists of digit characters. // For example, if numbers is {'1', '2', '5'}, the return value // should be 125. Please note that // numbers[0] is '1' // numbers[1] is '2' // numbers[2] is '5' int result = 0; for (int i = 0; i 4% Tue Jun 20 12:06:43 PM CR E Preview File Edit View Go Tools Window Help Introduction to java programming by Y Daniel Liang 10th edition copy a search v Introduction to java.programmin... 10.3 (The MyInteger class) Design a class named My Integer. The class contains pd 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 isEvenO, is0ddO, and isPrimeO that return true if the value in this object is even, odd, or prime, respectively L The static methods isEven Gint), isOddCint), and isPrime(int) that return true if the specified value is even, odd, or prime, respectively 422 The static methods isEvenCMyInteger), isoddCMyInteger), and isPrimeCMyInteger that return true if the specified value is even, odd or prime, respectively. PM The methods equals Cint) and equals(MyInteger that return true if the value in this object is equal to the specified value. A static method. parseInt Cchar Cl) that converts an array of numeric characters to an int value. A static method parselnt CString that converts a string into an int value Draw the UML diagram for the class and then implement the class. Write a cli- ent program that tests all methods in the class. 423 Upload Record Audio Choose Existing

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!