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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 24.06.2019 00:30, lovemusic4
Setting up a home network using wireless connections is creating a a. vpn b. lan c. wan d. mini-internet
Answers: 2
image
Computers and Technology, 24.06.2019 01:00, Timeisjesus
Answer these and get 40 points and brainliest
Answers: 1
image
Computers and Technology, 24.06.2019 10:30, brandon1748
You're programming an infinite loop. what must you include in your code to prevent crashes? in roblox
Answers: 2
image
Computers and Technology, 24.06.2019 16:50, yedida
Ideally, the backrest is tilted back slightly, so when you turn the wheel your shoulders are the seat.
Answers: 2
You know the right answer?
Here is the question: (The MyInteger class ) Design a class named MyInteger. The class contains:

Questions in other subjects:

Konu
Mathematics, 21.01.2021 07:50
Konu
Mathematics, 21.01.2021 07:50
Konu
Mathematics, 21.01.2021 07:50
Konu
English, 21.01.2021 07:50
Konu
Mathematics, 21.01.2021 07:50
Konu
Mathematics, 21.01.2021 07:50