Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please can someone answer this question correctly. Question 7. (30 pts) Write a complete Java program with comments in main and in each method Data:

Please can someone answer this question correctly. image text in transcribed
Question 7. (30 pts) Write a complete Java program with comments in main and in each method Data: The input data for this program is given as two columns of numbers a file named input.txt and all output will go to the screen. Assume there rows of data in the file. All data will be entered from w not be more than 100 Design a Java class with a main method that does the tollowing 1) Reads the data into two arrays of doubles, arr1 and arr2, by inwoking the methed readData. 2) Modifies all of the values in the arr2 array by inwoking the method changeArray, passing 3) Sort arrl 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 arays as parameters. The return value from readData shouls be stored in an integer variable num. both arrays and num as parameters and once for arr2 the numbers right aligned arrl arr2 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 [O] 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 th 164.92, is stored in beta[0] to beta. For example, beta[0],7, is multiplied by alpha[0], 23.56 and the resul 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MFDBS 89 2nd Symposium On Mathematical Fundamentals Of Database Systems Visegrad Hungary June 26 30 1989 Proceedings

Authors: Janos Demetrovics ,Bernhard Thalheim

1989th Edition

3540512519, 978-3540512516

More Books

Students also viewed these Databases questions

Question

Prove L={w: n a (w)=n b (w)*n c (w)} is not context free.

Answered: 1 week ago