Question: In this assignment, you are asked to implement a Java class named HugeInt for storing huge integers and performing mathematical operations on them. This class
In this assignment, you are asked to implement a Java class named HugeInt for storing huge integers and performing mathematical operations on them. This class must have a private variable of type LinkedListhBytei which stores digits of a huge integer and ten of the following public methods (choose ten methods out of 12):
1. public void setValue (int value): gets an integer (like 1234) as input parameter and stores its digits in the linked list in the same order as they appear in the input integer; e.g. for input equal to 1234, digit 1 is placed at the beginning of the list; while digit 4 is the placed at the end.
2. public void setValue (long value): Same as previous method; except the input type is long integer.
3. public int getValue (): returns 1 if the number stored in the linked list is too large to be fit in a Java int variable and returns the integer value of the stored number otherwise.
4. public HugeInt clone (): creates a copy of the integer stored in the linked list and returns the result as another HugeInt.
5. public long log (): counts and returns the number of digits stored in the linked list.
6. public HugeInt modExp (long n): calculates the remainder of the stored integer when dividing it by 10n and returns the result in the form of another HugeInt.
7. public HugeInt quotientExp (long n): calculates the quotient of the integer stored in the linked list when dividing it by 10n and returns the result in the form of another HugeInt.
8. public HugeInt timesExp (long n): calculate the product of 10n and the integer stored in the linked lists and returns the result in the form of another HugeInt.
9. public HugeInt add (HugeInt h): adds h with the integer stored in the linked list and returns the result as another HugeInt.
10. public void addSet (HugeInt h): adds h with the integer stored in the linked list and writes the result back on the linked list.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
