Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem Write a solution for the following problem in JAVA and TEST Harness: Giv

ID: 3711203 • Letter: P

Question

Problem

Write a solution for the following problem in JAVA and TEST Harness:

                Given a String containing n integer values, find all two-integer combinations in the candidate values list (the first n-1 values, preceding the semicolon) that sum to produce the nth value (the target value, following the semicolon).

EXAMPLE 1

The provided String:                   “1,2,3,4;5”

The “candidate” values are:        1,2,3 and 4

The “target” sum is :                      5

The valid combinations are:         1 + 4

2 + 3

EXAMPLE 2

The provided String:                   “2,3,5,2,6,4,4;8”

The “candidate” values are:        2, 3, 5, 2, 6, 4, and 4 (Note the duplicate values)

The “target” sum is :                      8

The valid combinations are:         2 + 6

3 + 5

2 + 6 (since 2 occurs twice, it generates two solutions)

4 + 4

EXAMPLE 3

The provided String:                   “3,0,5;8”

The “candidate” values are:        3, 0, and5

The “target” sum is :                      8

The valid combinations are:       3 + 5

NOTES ON SOULTION

1. The input is in the form of a single String object. That object must:

Be input by a user through the keyboard

Be broken into two parts: the candidates and the target

The candidate values must be separated into individual pieces

Each individual candidate value must be converted from a String or char to an INT value

Both the separation into candidates and target and the separation of individual candidate values may be done using methods of class String.

Conversion of the resulting String or CHAR value into an int value may be done using a wrapper class method.

2. It is necessary to move through the list of candidates values only once, in a single direction.

Explanation / Answer

Hi Dear,

Please find my implementation.

Output:

Provide String :

1,2,3,4;5

The provided String : 1234;5

The candidate values are: 1, 2, 3, and 4

The target sum is : 5

The valid Combinations are : 1 + 4

2 + 3

Process finished with exit code 0

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote