Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

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_2

Step: 3

blur-text-image_3

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

Intelligent Information And Database Systems Second International Conference Acids Hue City Vietnam March 2010 Proceedings Part 1 Lnai 5990

Authors: Manh Thanh Le ,Jerzy Swiatek ,Ngoc Thanh Nguyen

2010th Edition

3642121446, 978-3642121449

More Books

Students also viewed these Databases questions

Question

(b) What is the generator for this design? Pg45

Answered: 1 week ago

Question

please dont use chat gpt 5 0 4 .

Answered: 1 week ago