Question: (IncreaseDigits) Consider the following process applied to an ArrayList of Integer. The process replaces each digit 0..9 in the array with a digit one greater,


(IncreaseDigits) Consider the following process applied to an ArrayList of Integer. The process replaces each digit 0..9 in the array with a digit one greater, and 9 is replaced by 0. (Parta) Write a void method, increaseDigitsl, which receives an ArrayList of Integer, and that alters the array such that every digit from 0.9 is replaced with a digit one greater, and 9 is replaced by 0. Example: x 31 415 9 2 6 5 3 5 increaseDigits1(x) will alter the array x as follows. x 4 2 5 2 6 0 3 7 6 4 6 When writing this method, call and write another method called next Digit. The method next Digit(x) takes one integer argument (from 0 to 9), and returns the "next" one. For example, next Digit(6) - 7 and next Digit(9) -0. (Part b) Write another method, increaseDigits, that performs the same action upon the elements of the array passed to it but that does not alter the original array. Instead, the method should return an new ArrayList of Integer containing the result. Example: 15 9 2 6 5 3 5 4 increaseDigits2(x) will return a new array as follows. (array x will not be changed) y 4 2 5 2 6 0 1 76 4 6 Sample Output: 9, 2, 6, 5, 5 Original Array: Array: 3, 1, 4, 4, 1, 5, Part (a): using increaseDigits1 Array: 2, 5, 2, 6, Part (b): using increaseDigitsi Array: 5, 3, 6, 3, 7, 3, 4, 4, 0, 3, 7, 6, 6 1, 4, 8, 7, 5, 7 Compile Undo Cut Copy Paste Find... Close Source Code import java.util.*; public class FirstOddOccurrence { public static void main(String[] args) { int[] x = { 2, 4, 6, 7, 4, 3, 2, 7, 6, 7, 7 }; int i; display(x): System.out.printf("# Occurrences of first odd = %3d ", firstOddCount()); } private static void display( int(1 x) { int i; System.out.print("Array: "); for(i=0; i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
