Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Data: The input data for this program is given as two columns of integers. Input data will be read a file called inputData.txt You are

image text in transcribed
Data: The input data for this program is given as two columns of integers. Input data will be read a file called inputData.txt You are to read from the file until you reach end-of-file. All output will go to the Question 7. (25 pts) screen. Sample Data Set 25 16 100 31 Design a Java class with a main method that does the following: 1) Reads the data into two arrays, columnl and column2 by calling the method readData. The retum value from readData should be stored in an integer variable called num. Assume each array can store 1000 elements. 2) Modifies all of the values in the columnl array by calling method changeArray, passing both arrays and num as parameters. 3) Sorts both the columnl and column2 array by calling the method sortArray twice. 4) Prints the values in both arrays to the screen in two columns, in a similar format to the input data. Numbers should be right aligned in their columns. Method Details: The readData method reads in lines of data, each of which contains two integers. The first integer on each line is placed in arrOne, and the second integer is placed in arrTwo. For example, in the Sample Data above, 25 would go into arrOne[0] and 7 would go into arrTwo[0]. Parameters: arrone - an integer array for holding the 1st column in the data arrTwo - an integer array for holding the 2nd column in the data Returns: an integer representing the number of rows that were read in The changeArray method sets each of the first k elements in the alpha array to equal 5 times the corresponding value in the beta array. For example, if alpha[0] is 25, and beta[0] is 7, after this method executes, alpha[0]=35. Parameters: alpha - an integer array beta - an integer array -an integer representing the number of elements in alpha and beta to be processed. The sortArray method sorts the first k elements of the parameter array into ascending order. Parameters: arrToOrder - an integer array 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

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

3. What might you have done differently

Answered: 1 week ago

Question

4. Did you rethink your decision?

Answered: 1 week ago

Question

3. Did you seek anyones advice?

Answered: 1 week ago