Question: Can you please write a program in terms of java & provide me with an output? Problem Description We are given an input file that




Can you please write a program in terms of java & provide me with an output?
Problem Description We are given an input file that contains word SumOfK, "target" numberk, and a sequence of numbers. We want to determine if there are two numbers whose sum equals the given "target" number K. For instance, if the input file contains SumOfK // word // "target" number 8416 // sequence of N numbers We know from the file that Kis 10, sequence of numbers is 8 4 1 6, and number of elements Nis 4 (we can count numbers). In this case, the answer is yes, there are two such numbers (4 and 6), because 4+6 is 10. One number may be used twice (doubled). If the input file is 10 SumOfK 10 8453 the answer is also yes, because 5+5 is 10. Exercise1 Program Devise an O(N) algorithm to solve this problem. Code the solution. The program has to read 5 input files and print the results to corresponding 5 output files. All files have to be processed in one program run. The input files have to be named inx.txt and the output files have to be named outx.txt (where X is 1, 2, 3,4,5) The input and output files shall be in format similar to the examples below. The instructor will use different numbers to test your program. Input and Output Files Test and Sample Files There are five test input files provided - in1.txt, in2.txt, in3.txt, in 4.txt and ins.txt. There are also four sample output files corresponding to the input files - out1_sample.txt, out2_sample.txt, out3_sample.txt and out4_sample.txt (file out5_sample.txt is not provided) Correspondent correspondent Correspondent Correspondent Correspond files files files files ent files Provide in1.txt in2.txt in3.txt in4.txt In5.txt d test input files Provide out1_sample.txt out2_sample.txt out3_sample.txt Out4_sample.txt none d sample output files Output out1.txt out2.txt out3.txt out4.txt out 5.txt files to produce The format of the produced output files shall be similar to the provided sample output files. The results have to be the same. Run your program using all five test input files to produce five output files and submit the input and output files together with the source code. Compare the output files produced by your program with the sample files. Submit the test input and the produced output files together with the program source code. Examples An example of two numbers In the case of input file Sumok 10 8416 Output file has to be OT 8416 Yes 4+6=10 An example of one doubled number In the case of input file Sumok 10 8453 Output file has to be 10 8453 Yes S+5=80 An example where there is no solution In the case of input file SumOfK 11 +5 - 8451 Output file has to be 11 8451 No
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
