Question: Write a program that accepts an array and a number, then find two elements of the array, which their sum is equal to the given
Write a program that accepts an array and a number, then find two elements of the array, which their sum is equal to the given number.
a. The method should return -1 if the value is not found.
b. Finding one occurrence is enough.
c. Size of the arrays must be at least three.
d. You can get the input from the user by use of Scanner class.
For example, if your array contains {1,2,3,4,5} and the given value is 7, then your program should find 2 and 5.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
