Question: (26%) Create a C# class HugeInteger of 5 element array. Here an int array of 5 elements like {1, 2, 3, 4, 5} can represent

(26%) Create a C# class HugeInteger of 5 element array. Here an int array of 5 elements like {1, 2, 3, 4, 5} can represent either the integer 12345 or the integer 54321. Please clearly state which way you want to do.

Lets suppose your {1, 2, 3, 4, 5} means 54321 using an int array of 5 elements. This is very similar to the sum of two polynomials as in Q4, except if we add {1, 2, 5, 5, 4} and { 1, 2, 5, 5, 4} as two polynomials, we get {2, 4, 10, 10, 8} since the sum of polynomials 4x4 + 5x3 + 5x2 + 2x + 1 and 4x4 + 5x3 + 5x2 + 2x + 1 is 8x4 + 10x3 + 10x2 + 4x + 2, but if we add {1, 2, 5, 5, 4} and { 1, 2, 5, 5, 4} as two HugeIntegers of 5 digits, then we get {2, 4, 0, 1, 9} since 45521 + 45521 = 91042 as a 5 digits integer.

(4%) Define the HugeInteger class with 5 elements arrays. Add either Input method that Deitel suggested or a constructor from integer like HugeInteger (int a), that will convert integer 54321 to the array {1, 2, 3, 4, 5}.

(6%) Create the Sum method of two HugeIntegers of 5 elements (5 digits). Note {1, 2, 5, 5, 4} + {1, 2, 5, 5, 4} = {2, 4, 0, 1, 9}. We do not worry about the overflow case at this moment, i.e. {1, 2, 3, 4, 5} + {1, 2, 3, 4, 5} = {2, 4, 6, 8, 10} or {2, 4, 6, 8, 0, 1}, a HugeInteger array of 6 elements

(10%) Create the product method of two Huge Integers of 5 elements. Note that after multiplying two integers of 5 digits, you get an integer of 9 or 10 digits (since 11*11 = 121 is 3 digits and 99*99 = 9801 is 4 digits). Now you may need HugeIntegers of 10 elements.

(6%) Use test data to verify that your part (a), (b) (sum), and (c) (product) works.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!