subject

Here is the 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(), isOdd(), and isPrime() that return true if the value in this object is even, odd, or prime, respectively.
* The static methods isEven(int ), isOdd(int ), and isPrime(int ) that return true if the specified value 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) that return true if the value in this object is equal to the specified value .
* A static method parseInt(char []) that converts an array of numeric characters to 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 the class . Write a client program that tests all methods in the class . Given that the definition of a prime number is a positive integer be sure to instruct the use to only enter positive integers .
SAMPLE RUN #2
Need Help with this part...
--- Prompts For Keyboard/Console/Standard Input ---
Enter a positive integer to create a MyInteger object or to move on to next part of program :
Enter a positive integer to test static isXXX(int ) methods or to move on to next part of program :
Enter a positive integer to test static isXXX(MyInteger) methods or to move on to next part of program :
Enter a the first of two positive integers to create obj2 and test obj2.equals (int ) or to move on to next part of program :
Enter a the second of two positive integers to test obj2.equals (int ):
Enter a the first of two positive integers to create obj2 and test obj2.equals (MyInteger obj3) or to move on to next part of program :
Enter a the second of two positive integers to create obj3 and test obj2.equals (MyInteger obj3):
Enter a positive integer that will be placed into a char [] array to demonstrate the MyInteger. parseInt(char []):
Enter a positive integer that will be placed into a String to demonstrate the MyInteger. parseInt(String ):
Inputs
--- Keyboard/Console/Standard Input stdin ---
1
4
6
9
12
11
108
109
111
89
46
47
48
49
37
37
112
122
112
112
189222
333
107
22897
203
207
201
7
So Far I have the following code but need to test it:
import java. util.*;
public class MyInteger {
// store value
private int value;
//constructor for MyInteger
public MyInteger(int value){
this. value = value;
}
// Getter method to return in value
public int getValue(){
return value;
}
//Method for even
public boolean isEven(){
return(value%2 == 0);
}
// Method for odd
public boolean isOdd(){
return(value%2!=0);
}
// Method for prime
public boolean isPrime(){
if (value == 2)return true;
for (int i = 2; i*i<=value; i++){
if(value%i==0) return false;
}
return true;
}
// static method isEven
public static boolean isEven(int val){
return(val%2 == 0);
}
//static method isOdd
public static boolean isOdd (int val){
return(val%2!=0);
}
//static method isPrime
public static boolean isPrime(int val){
if(val==2)return true;
for(int i=2; i*i if(val%i==0)return false;
}
return true;
}
// static method return for is even
public static boolean isEven(MyInteger M){
return M. isEven();
}
// static method return for is odd
public static boolean isOdd(MyInteger M){
return M. isOdd();
}
// static method return for is prime
public static boolean isPrime(MyInteger M){
return M. isPrime();
}
//true if value in object = specified value
public boolean equals(int val){
return value == val;
}
public boolean equals(MyInteger M){
return value==M. value;
}
//static method parseInt convert array char to int value
public static int parselInt(char[] val){
int num = 0;
for(int i=0; i num = 10*num + (int)(val[i]-'0');
return num;
}
//static method parseInt String
public static int parseInt(String val){
int num = 0;
for(int i=0; i num = 10*num + (int)(val. charAt(i)-'0');
return num;
}
// test program
public static void main(String[] args){
Scanner input = new Scanner(System. in);
need suggestion on how to do the second part of the code..

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 09:30
Light travels at a speed of 186,000 miles a second. the distance light travels in a year is 5,865,690,000,000 miles/year 5,865,695,000,000 miles/year 58,656,950,000,000 miles/year 6,789,000,0000 miles/year
Answers: 1
question
Computers and Technology, 23.06.2019 12:00
Which of these is a benefit of using objects in a powerpoint presentation? a. collaborators can create the external files while you create and edit the slide show. b. you can easily change the theme and design of the presentation. c. you can have older data in the source file while having up-to-date data in the presentation. d. collaborators can easily share the presentation.
Answers: 2
question
Computers and Technology, 23.06.2019 13:30
Spoons are designed to be used for: spring hammering. applying body filler. identifying high and low spots. sanding highly formed areas.
Answers: 3
question
Computers and Technology, 24.06.2019 18:30
Jacking is a crime that takes place when a hacker misdirects url to a different site. the link itself looks safe, but the user is directed to an unsafe page
Answers: 1
You know the right answer?
Here is the question: (The MyInteger class ) Design a class named MyInteger. The class contains:
Questions
question
History, 29.12.2020 16:20
question
Mathematics, 29.12.2020 16:20
question
Business, 29.12.2020 16:20
question
Health, 29.12.2020 16:20
question
Mathematics, 29.12.2020 16:30
question
Advanced Placement (AP), 29.12.2020 16:30
question
English, 29.12.2020 16:30
question
Mathematics, 29.12.2020 16:30