Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please follow the instructions in image 2 This program should print out all common elements of two given arrays Two testing arrays a and b

Please follow the instructions in image 2 image text in transcribed
image text in transcribed
This program should print out all common elements of two given arrays Two testing arrays a and b are created at the beginning of the program Your first task is to create two methods at test them: printMyArray (int [] arr) and hasElement(int [] arr, int x) printMyArray() should simply print out all elements of the given array hasElement, takes and array of integers arr and an integer number x as inputs and returns true if arr has even one element equal to x. Otherwise it should return false. Your next task is to finish the main: 1. Print out given arrays a and b using printArray method 2. In a loop, use method hasElement() to check if any element of a is contained in b. If it is, print out that this element is a common element. Your output should look like this: Array a: 1 2 34 5 12 Array b: 2 56712 Common element:2 Common element: 5 Common element: 12

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

Students also viewed these Databases questions

Question

28. Write each function of Exercise 23 with the pi notation.

Answered: 1 week ago