Question: JAVA Please adhere to the instructions. Thank you in advance. start code (with parameters to help): import java.util.Arrays; public class BigIntAddition { public static void
JAVA Please adhere to the instructions. Thank you in advance.
start code (with parameters to help):
import java.util.Arrays;
public class BigIntAddition {
public static void main(String [] args) {
addBigIntTest();
convertStringToBigIntTest();
}
/**
* Performs addition of number1 and number2 and writes the result in answer.
* Each element in an array holds a single digit, 0-9, of the number.
* No element in any array holds a value greater than 9.
*
* @param number1 - holds the first number to be added
* @param number2 - holds the second number to be added
* number1 and number2 are guaranteed to be the same length.
* @param answer - passed in filled with zeros and is large enough to hold the answer
* When this method is complete, answer holds the result of the addition.
*
*/
public static void addBigInts(int[] number1, int[] number2, int []answer) {
}
/**
* Converts the strValue passed in into an array representation of a number in
* the format used by addBigInts
* @param strValue - string value to be converted
* @param number - passed in filled with zeros and is large enough to hold the number
* When this methos is complete, number holds the converted value.
*/
public static void convertStringToBigInt(String strValue, int [] number) {
// Use Integer.parseInt(String) to convert a string number into a decimal number
}
INSTRUCTIONS

Part 1 bigintAddition (5 points) In BigIntAddition.java there is this empty method for you to complete: void addBigInts(int [] numberi, int[] number2, int[] answer) numberl and number2 hold the numbers to be added. numberl and number2 are always the same length. answer is initialized with zeros, and is large enough to hold the result. When the method is complete, answer holds the result of adding number1 and number2. This method is tested by addBigInt Tests() in BigIntAdditiona.java. Problem Description: Java has a size limit on the largest integer value it can represent, 2147483647. We want to create a method that can add numbers of any size. To do this, we will hold the numbers in arrays of integers. No single array element holds a value greater than 9! EX: Array holding the number 5241 Element O holds the 10' value (1). index 0123 Element 1 holds the 10' value (4). value Element 2 holds the 10' value (2). Element 3 holds the 10' value (5). Don't be confused because we draw arrays from lowest index to highest. The least significant digit is in index zero. You do the addition just like you did in grade school. Example adding 96 + 7 = 103 number 1 carry 1 1 index 01 number2 9 6 value 69 index 0 1 index 012 70 1 0 3 value 30 1 answer + 0 7 value Part 2: convertStringToBigInt (5 points) Do not use charAt in this problem, use substring! Complete this method in BigIntAddition.java void convertStringToBigInt(String strValue, int[] number)! number is initialized with zeros, and always large enough to hold the answer You do not have to create number in your code! Convert a String representation of a number into an array representation of a number. String "54321" index 0 1 2 3 4 "5" 4" "3" "2" "1" array 0 1 2 3 4 index value 1234 5 Note how the values are located at opposite indices
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
