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, 21.06.2019 19:40
Write the quartstogallons java class that declares a named constant to hold the number of quarts in a gallon (4). also declare a variable to represent the number of quarts needed for a painting job, and assign an appropriate value—for example, 18. compute and display the number of gallons and quarts needed for the job. display explanatory text with the values, for example:
Answers: 2
question
Computers and Technology, 22.06.2019 15:00
Which of the following has not been attributed at least in part to social media a. drug addiction b. depression c. kidnapping d. murder
Answers: 2
question
Computers and Technology, 23.06.2019 05:00
Jason works as an accountant in a department store. he needs to keep a daily record of all the invoices issued by the store. which file naming convention would him the most?
Answers: 2
question
Computers and Technology, 23.06.2019 11:00
In the context of the box model, what is the difference between a margin and a padding? a. a padding lies outside a box border, while a margin lies inside it. b. a padding lies inside a box border, while a margin lies outside it. c. a padding can be adjusted independently, while a margin depends on the size of its box. d. a padding depends on the size of its box, while a margin can be adjusted independently.
Answers: 3
You know the right answer?
Here is the question: (The MyInteger class ) Design a class named MyInteger. The class contains:
Questions
question
Mathematics, 18.06.2021 17:30
question
Mathematics, 18.06.2021 17:30
question
Social Studies, 18.06.2021 17:30
question
Computers and Technology, 18.06.2021 17:30
Questions on the website: 13722363