Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started