Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[10 pts] Write a method called checkArrays that accepts as parameters two arrays of integer (A and B of the same size) and returns another

image text in transcribedimage text in transcribed

[10 pts] 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 6 24 15 9 1 0 0 1 0 Use the following method header: public static int[] checkArrays (int[ ] A, int[ ] B) [5 pts] 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) O [10 pts] 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). - Sample Run: 4 ArrayA: 12 ArrayB: 3 ArrayC: 1 20 6 0 30 15 1 17 9 24 0 O 0 Problem #3: [25 pts] Arrays and Methods 0 [10 pts] 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 6 24 15 9 1 0 0 1 0 Use the following method header: public static int[ ] checkArrays (int[ ] A, int[ ] B) . [5 pts] 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) . [10 pts] Write a main method to test the above methods as follows: Declare and initialize 2 integer arrays (array A 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). Sample Run: 20 17 ArrayA: 12 ArrayB: 3 ArrayC: 1 4 24 6 30 15 1 9 0 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students also viewed these Databases questions

Question

=+ Are unions company-wide, regional, or national?

Answered: 1 week ago

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago