oldi and old2 arrays, as follows. Each element of sumarr will be equal to the sum of the correspondir elements of gldi and gld2. For example, sumarri0] will be oldi[0]+old2[0], sumarr[1] will be oldi[1]- old2[1] and so on. (You are using parallel arrays.) te a complete Java program to do the following: the main program will call a series of methods to ocess a set of data. One method will read data into two arrays. A second method will print the values red in an array. A third method will find the smallest of the values stored in an array. A fourth method I construct a new array from two existing arrays. A fifth method will compare the values in the two ays. Use files for both input and output. Be sure to pass the file variable to any method that will need E. The method whatsHigher will receive three parameters: two arrays (called scorel and score2), and integer n(giving the size of the two arrays). The method will compare the two arrays, element by eler to calculate in which array the value is higher. For each array element, the method will print which an the higher value (or if the two values are equal). The method should print each of the values, the arra from and the relationship. For example, for the data above, the method should print something like t following messages: The main program will read in a from the input file and call a method readData to read n items into two ays (which the main program will call scorel and score2). All data values must be read from a file, and all ues except the parameter value must be read in the method. Assume there are maximum 50 pairs of ues to read. In position O the higher value is in array score1: 18 is higher than 13 in position 1 the higher value is in array score2: 42 is higher than 21 in position 2 the value is the same in both arrays: 66 The main program will call a method printArray twice to print the values stored in the two arrays. (Call e method once to print array scorel and once to print array score2) Each time before the main program Is the printing method, it should print a heading saying what is being printed (for example, it could say orel array"). All output, including headings should go to a file. in addition, the method counts how many times the value from scorel is larger, how many times the from score2 is larger, and how many time the values in the two arrays are equal. Use local variables fo counters. Print these values before returning to the main method. For each array, the main program willi call a method smallest which will find the smallest of the n values red in an array. The main program will call the method once to find the smallest of the n values stored in escorel array, and once to find the smallest of the n values stored in the score2 array. After each call, the in program will print the returned value, together with a relevant message. DATA: Please read the data from a file which is to be prepared in advance (be sure to submit the file). parameter value of 10-15, but write a program which will work for any size arrays up to 50 or so. Mak that the smallest element does not occur in the first or the last position of an array. Make sure that th smallest element does not occur at the same position in each array. Make sure that the two arrays ha same value in at least one position. Try to make sure that the value make the counters printed at the have 3 different values. The main program will call a method construct. The method will construct a new array (which the main ogram will call sumscore) from the two arrays scorel and score2 Then construct will call printarray to nt the sumscore array. Either main or the method construct can print the heading for the sumscore ay. The sumscore array will need to be sent back to the main program, either as a return value or as an ay parameter. SAMPLE INPUT AND OUTPUT: (make yours larger) Input: The main program will call the method smallest again to find the smallest of then values stored in the mscore array. The main program will print this value. 6 95 94 98 98 The main program will call a method whatsHigher. This method will be used to compare the contents of scorel and score2 arrays. The method will receive three parameters: two arrays (scorel and score2), d an integer a (giving the size of the two arrays). The method will compare the two arrays, element by ment, to calculate in which array the corresponding value is higher. It will also count how many times e value in scorel is higher, and how many times in score2 is higher. It will print the counters, together ch clear messages 42 45 43 18 64 54 83 79 Sample output for this data file fyour order and words might be slightly different): re are the details of the methods. There are 6 values in each array The scorel array: 95 98 42 43 64 83 The method readData will read the data into two arrays. The method will receive three parameters: an eger n and two arrays which it calls numsi and nums2 At the beginning, only the parameter n will have alue. The value of a will be used to control the action of the method, as described below. The method will read n sets of data. Each set of data should contain two integers; the first will be read o nums1, and second will be read into nums2. (The values stored in these parameters will remain when e method returns to the main program, and they can be used throughout the program.) For example, opose the data set is the following The score2 array: 94 98 45 18 54 79 The smallest value in scorel is 42 The smallest value in score2 is 18 The sumscore array: 189 196 87 61 118 162
oldi and old2 arrays, as follows. Each element of sumarr will be equal to the sum of the correspondir elements of gldi and gld2. For example, sumarri0] will be oldi[0]+old2[0], sumarr[1] will be oldi[1]- old2[1] and so on. (You are using parallel arrays.) te a complete Java program to do the following: the main program will call a series of methods to ocess a set of data. One method will read data into two arrays. A second method will print the values red in an array. A third method will find the smallest of the values stored in an array. A fourth method I construct a new array from two existing arrays. A fifth method will compare the values in the two ays. Use files for both input and output. Be sure to pass the file variable to any method that will need E. The method whatsHigher will receive three parameters: two arrays (called scorel and score2), and integer n(giving the size of the two arrays). The method will compare the two arrays, element by eler to calculate in which array the value is higher. For each array element, the method will print which an the higher value (or if the two values are equal). The method should print each of the values, the arra from and the relationship. For example, for the data above, the method should print something like t following messages: The main program will read in a from the input file and call a method readData to read n items into two ays (which the main program will call scorel and score2). All data values must be read from a file, and all ues except the parameter value must be read in the method. Assume there are maximum 50 pairs of ues to read. In position O the higher value is in array score1: 18 is higher than 13 in position 1 the higher value is in array score2: 42 is higher than 21 in position 2 the value is the same in both arrays: 66 The main program will call a method printArray twice to print the values stored in the two arrays. (Call e method once to print array scorel and once to print array score2) Each time before the main program Is the printing method, it should print a heading saying what is being printed (for example, it could say orel array"). All output, including headings should go to a file. in addition, the method counts how many times the value from scorel is larger, how many times the from score2 is larger, and how many time the values in the two arrays are equal. Use local variables fo counters. Print these values before returning to the main method. For each array, the main program willi call a method smallest which will find the smallest of the n values red in an array. The main program will call the method once to find the smallest of the n values stored in escorel array, and once to find the smallest of the n values stored in the score2 array. After each call, the in program will print the returned value, together with a relevant message. DATA: Please read the data from a file which is to be prepared in advance (be sure to submit the file). parameter value of 10-15, but write a program which will work for any size arrays up to 50 or so. Mak that the smallest element does not occur in the first or the last position of an array. Make sure that th smallest element does not occur at the same position in each array. Make sure that the two arrays ha same value in at least one position. Try to make sure that the value make the counters printed at the have 3 different values. The main program will call a method construct. The method will construct a new array (which the main ogram will call sumscore) from the two arrays scorel and score2 Then construct will call printarray to nt the sumscore array. Either main or the method construct can print the heading for the sumscore ay. The sumscore array will need to be sent back to the main program, either as a return value or as an ay parameter. SAMPLE INPUT AND OUTPUT: (make yours larger) Input: The main program will call the method smallest again to find the smallest of then values stored in the mscore array. The main program will print this value. 6 95 94 98 98 The main program will call a method whatsHigher. This method will be used to compare the contents of scorel and score2 arrays. The method will receive three parameters: two arrays (scorel and score2), d an integer a (giving the size of the two arrays). The method will compare the two arrays, element by ment, to calculate in which array the corresponding value is higher. It will also count how many times e value in scorel is higher, and how many times in score2 is higher. It will print the counters, together ch clear messages 42 45 43 18 64 54 83 79 Sample output for this data file fyour order and words might be slightly different): re are the details of the methods. There are 6 values in each array The scorel array: 95 98 42 43 64 83 The method readData will read the data into two arrays. The method will receive three parameters: an eger n and two arrays which it calls numsi and nums2 At the beginning, only the parameter n will have alue. The value of a will be used to control the action of the method, as described below. The method will read n sets of data. Each set of data should contain two integers; the first will be read o nums1, and second will be read into nums2. (The values stored in these parameters will remain when e method returns to the main program, and they can be used throughout the program.) For example, opose the data set is the following The score2 array: 94 98 45 18 54 79 The smallest value in scorel is 42 The smallest value in score2 is 18 The sumscore array: 189 196 87 61 118 162
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY