Problem

Write a class called WholeNumber class. The whole numbers are the non-negative integers: 0...

Write a class called WholeNumber class. The whole numbers are the non-negative integers: 0,1,2, . . . Your class must handle addition, subtraction, and multiplication of whole numbers—no division or mixed-type (whole number and integer) operations need be handled. Your class must also handle printing—e.g., if x is an instance of the WholeNumber class, you must be able to write print x.

Two cases must not be allowed: (1) you must not be able to create a WholeNumber that has a negative value; (2) an arithmetic operation cannot be allowed to have a negative result. In both cases, an error message must be printed.

Remember that arithmetic must return a whole number. That is, if x and y are whole numbers, the result of x + y must be a whole number.

Include sample code that uses your class and demonstrates the use of all methods as well as error handling.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 12
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT