Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Description Design a class named MyInteger. The class contains: 1) An int instance variable named value, which stores the integer value represented by this object.

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Description Design a class named MyInteger. The class contains: 1) An int instance variable named value, which stores the integer value represented by this object. 2) A constructor that creates a MyInteger object for the specified int value. The constructor should have an input parameter that initializes value. 3) A get method, which returns the int value. 4) Methods is Even(), isOdd () and isPrime(), which return true if the value is even, odd, or prime, respectively. 5)A method equals(int), which returns true if the value in the object is equal to the argument. A tester class MyIntegerTester has been provided with the assignment. You can test your class using the tester class. Submission 1) You should create a folder named programl" in your server account. All source code should be put in the folder. The code should NOT be modified after the due date. Altered code will be considered late. 2) The instructor should be able to use javac and java to compile and run the program, respectively. 3) You should also submit a report on the due date. The report should include the following items: 3) You should also submit a report on the due date. The report should include the following items: a) Your name b) The assignment name c) Your server username d) The output of MyIntegerTester based on your MyInteger class. e) The source code of MyInteger Notes 1) To receive credit for an assignment, you must be able to explain to the instructor) how your program works. You must not misrepresent the output of your program. Violators of any of these policies will receive a grade of zero on the assignment. The instructor shall be the sole judge in these matters. 2) No points, zero (0), will be given to any program containing compilation errors. 3) Program grades reflect both the performance of the program and the programming style of the program. Examples of poor programming style include: a) inadequate use of methods b) non-meaningful variable names c) inadequate use of structures d) poor comments e) poor program design /** A class that tests the MyInteger class. */ public class MyIntegerTester { /** The main method that tests the My Integer class. public static void main(String[] args) { System.out.println("Current int value is + (new MyInteger (0)).get() + "."); if ((new MyInteger (88)).isEven() System.out.println("88 is even."); else System.out.println("isEven() method has some problem."); if ((new MyInteger(-77)).isOdd()) System.out.println("-77 is odd."); else System.out.println("isOdd() method has some problem."); if (! (new MyInteger (-5)).isPrime() System.out.println("-5 is not a prime number."); else System.out.println("isPrime() method has some problem."); if (! (new MyInteger (0)).isPrime()) System.out.println("O is not a prime number."); else System.out.println("isPrime() method has some problem."); if (!(new MyInteger (1)).isPrime()) System.out.println("1 is not a prime number." else System.out.println("isPrime() method has some problem."); if (!(new MyInteger (91)).isPrime()) System.out.println("91 is not a prime number."); else System.out.println("isPrime() method has some problem."); if ((new My Integer (2)).isPrime()) System.out.println("2 is a prime number."); else System.out.println("isPrime() method has some problem."); if ((new My Integer (3)).isPrime()) System.out.println("3 is a prime number."); else System.out.println("isPrime() method has some problem."); if ((new My Integer (5)).isPrime()) System.out.println("5 is a prime number."); else System.out.println("isPrime() method has some problem."); if ((new My Integer (79)).isPrime() System.out.println("79 is a prime number."); else System.out.println("isPrime() method has some problem."); if ((new My Integer (100)).equals (100)) System.out.println("100 equals 100."); else System.out.println("equals() method has some problem.")

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What is the education level of your target public?

Answered: 1 week ago

Question

Define hypothesis? List the five steps in hypothesis testing.

Answered: 1 week ago

Question

6. What questions would you suggest should be included?

Answered: 1 week ago

Question

5. Who should facilitate the focus group?

Answered: 1 week ago