Question: Java class MyNumber represents a non-negative integer. Provide the constructor: public MyNumber(int value) If value is negative, multiply if by -1 so that you do
Java class MyNumber represents a non-negative integer. Provide the constructor: public MyNumber(int value) If value is negative, multiply if by -1 so that you do not have a negative number. You should call method setNumber() and do not write the validity check code twice. Provide methods: public int getNumber() Gets this number. public void setNumber(int value) Sets the stored number to a new value. If value is negative, multiply if by -1 so that you do not have a negative number. public int digitCount() Gets the number of digits in this number. public String formatWithComma() Gets a string representing the number in the comma format, if the number is less than 1,000,000. If the number is greater than or equal to 1,000,000, return the string "too big". You must define constants for all numbers used in the program, except -1. Hint: You can convert a number to a string by concatenating it with the empty string.
Please Include Output...
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
