1. Engineering
  2. Computer Science
  3. question 7 30 pts write a gomplete java program with...

Question: question 7 30 pts write a gomplete java program with...

Question details

Question 7. (30 pts) Write a gomplete Java program with comments in main and in each method Data: The input data for this program is given as two columns of numbers. All data will be rows of data in the file a file named input.txt and all output will go to the screen Assume there will not be mor 7 23.56 16 88.12 10 75. Design a Java class with a main method that does the following 1) Reads the data into two arrays of doubles, arr1 and arr2, by invoking the method readData. 2) Modifies all of the values in 3) Sort arri and arr2 separately by invoking the method sortArray twice-once for arrl 4) Prints the values in both arrays to the screen in two columns as shown below with a header and with both arrays as parameters. The return value from readData should be stored in an integer variable num the arr2 array by invoking the method changeArray, passing both arrays and num as parameters and once for arr2 the numbers right aligned arrlarr2 7.00 164.92 10.00 751.00 16.00 1409.92 The readData method reads two doubles values from the input file. The first value of each line is stored in arrOne, and the second value is stored in arrTwo. For example, in the Sample Data above, 7 would go into arrOne[0] and 23.56 would go into arrTwo [O]. This is repeated until there are no more values in the file. Parameters arrOne- an array of doubles for storing the 1st value read in per row arrTwo - an array of doubles for storing the 2nd value read in per row Returns: num- an integer representing the number of rows that were read in The changeArray method has parameters: alpha - an array of doubles beta- an array of doubles k - an integer representing the number of elements in alpha and beta to be processed The method multiplies each element of beta by the corresponding value of alpha and stores the result into beta. For example, beta[0],7, is multiplied by alpha[0], 23,56 and the result, 164.92, is stored in beta [0] The sortArray method sorts the first k elements of the parameter array into ascending order. Parameters: arrToOrder- an array of doubles to be sorted k - an integer representing the number of elements in the array arrToOrder
Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution