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, 22.06.2019 04:30
How can you know if the person or organization providing the information has the credentials and knowledge to speak on this topic? one clue is the type of web site it is--the domain name ".org" tells you that this site is run by a nonprofit organization.
Answers: 2
question
Computers and Technology, 23.06.2019 12:30
What is the difference between the internet and the world wide web?
Answers: 1
question
Computers and Technology, 23.06.2019 19:30
Anul 2017 tocmai s-a încheiat, suntem trişti deoarece era număr prim, însă avem şi o veste bună, anul 2018 este produs de două numere prime, 2 şi 1009. dorel, un adevărat colecţionar de numere prime, şi-a pus întrebarea: “câte numere dintr-un interval [a,b] se pot scrie ca produs de două numere prime? “.
Answers: 1
question
Computers and Technology, 24.06.2019 23:30
Game design colleges anyone know the requirements? ?
Answers: 1
You know the right answer?
Here is the question: (The MyInteger class ) Design a class named MyInteger. The class contains:
Questions
question
Advanced Placement (AP), 26.10.2020 18:50
question
Mathematics, 26.10.2020 18:50
question
Mathematics, 26.10.2020 18:50
question
Mathematics, 26.10.2020 18:50
Questions on the website: 13722367