Question: 2. Check diot (30 points). Write a program CheckDigitava that takes a 12 or 13-digit long as a commandine argument and plays the digle computed
2. Check diot (30 points). Write a program CheckDigitava that takes a 12 or 13-digit long as a commandine argument and plays the digle computed as follows: - Take for an example the number 048231312622 Sum every other digit of the codo, starting from the right. In the example, that is 246 +1+1+2+4=16. Discard the one dipt and kop the onos digit, 6. Start with the second to last digit and do the same thing. Sum the digits, discard the tone digit and keep the ones digit. In this example this is 2+2+3+3+8+ 0m18. Discarding the 10 leaves 8. Multiply this number by 3 and again discard the tens digit 324, leaving 4 - Add the numbers from stope 1 and 2. Again drop the tons digit 6.410, leaving the digitizero). Hint 1: the maximum value that can be stored in an integer variable is 2147483647 which is only 10 digits tong To read a 12 of 13 digit integer from command line argument you will need to store it in a long variable. Use: long number Longparselong(argo, to read a long from the command line Hint 2: to extract the rightmost digit of a number use the modulus operator, Hint 3: to remove the rightmost digit of a numbo use the integer division by 10 Hint 4 for full credit use a loop to compute the sums Assume the input value used to test your program is a 12 or 13-digit positive integer Java CheckDigit 048231312622 0 Java Check Digit 9780470454310 8
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
