Write a method called checkArrays that accepts as parameters two arrays of integer (A and B of the same size) and returns another array of integers (C) initialized as follows: C[i] = 1 if B[i] divides A[i], otherwise C[i]=0. For example: A 12 20 4 30 17 B 3 1 6 24 15 9 0 0 1 0 se the following method header;

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter10: Classes And Data Abstraction
Section: Chapter Questions
Problem 22PE
icon
Related questions
Question
100%
.
-
Write a method called checkArrays that accepts as parameters two arrays of integer (A
and B of the same size) and returns another array of integers (C) initialized as follows: C[i] = 1
if B[i] divides A[i], otherwise C[i]=0. For example:
A 12 20 4 30
3 6 24
C 1 0 0 1
B
Use the following method header:
public static int[] checkArrays (int[] A, int[ 1 B)
Sample Run:
15
Write a void method called printArray that accepts as parameters an array of integers and
print its values. Use the following method header:
public static void printArray (int[] arr)
ArrayA: 12
ArrayB: 3:
ArrayC: 1
17
260
9
Write a main method to test the above methods as follows:
Declare and initialize 2 integer arrays (arrayA and arrayB) of size 5 (fill the 2 arrays with random
integers between 1 and 100).
Invoke the method printArray to display the values stored in the two arrays.
Invoke the method checkArrays and pass to it the two arrays arrayA and arrayB.
Invoke the method printArray to display the values of the new array(arrayC).
20
0
4
24
0
30
15
1
17
9
0
Transcribed Image Text:. - Write a method called checkArrays that accepts as parameters two arrays of integer (A and B of the same size) and returns another array of integers (C) initialized as follows: C[i] = 1 if B[i] divides A[i], otherwise C[i]=0. For example: A 12 20 4 30 3 6 24 C 1 0 0 1 B Use the following method header: public static int[] checkArrays (int[] A, int[ 1 B) Sample Run: 15 Write a void method called printArray that accepts as parameters an array of integers and print its values. Use the following method header: public static void printArray (int[] arr) ArrayA: 12 ArrayB: 3: ArrayC: 1 17 260 9 Write a main method to test the above methods as follows: Declare and initialize 2 integer arrays (arrayA and arrayB) of size 5 (fill the 2 arrays with random integers between 1 and 100). Invoke the method printArray to display the values stored in the two arrays. Invoke the method checkArrays and pass to it the two arrays arrayA and arrayB. Invoke the method printArray to display the values of the new array(arrayC). 20 0 4 24 0 30 15 1 17 9 0
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage