Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java: Enter 6 doubles then put into an array. Take the 1st array and square it to produce new second array. Then compare the largest

image text in transcribed

Java: Enter 6 doubles then put into an array. Take the 1st array and square it to produce new second array. Then compare the largest value in 1st array to smallest value in squared array and print if 1st array largest value was larger, smaller, or equal to smallest 2nd array value.

Task 4 (45 pts) Project: HW6 ArrayPractice Implement the following methods: 1. doublel] readArray(int N) takes as argument an integer N, and creates an array of N real numbers (of type double) and populates it with data read from the user void printArray (doublet) arr1) - prints the elements from arr l on the same line. The output should be f 3. double[] squareArray (doublel) arri) - takes as argument an array, arr1, of doubles and returns another aray wit the squares formatted (7 reserved spaces and 2 digit precision) such that the numbers are aligned. d returns another array with the squares of the numbers in arr1. Do whatever you need in main to produce the behaviour shown in the sample run. The last line compares the largest number in the original with the smallest number in the squares array and prints: the proper place in the text. LARGER, SMALLER or FQUAL in Sample run 1 (Here the largest in the original array is 8 and the smallest in the squares array is 4.46 Since 8 4.46, it prints SMALLER in the last line ) Enter 6 integers separated by a space: 3.205 2.1111 5.3 4.9 5.7 original array 3.21 2.11 5.3 . 4,90 5.70 10.27 4.46 28.8964.00 24,01 32.49 quared array The largest value in the original array ?s LARGER than the snaiest value in the squares are Sample run 2 Enter 6 integers separated by a space: 1.099 2.2 3.302 4.4 S.5 6.6 original array: squared array The largest value in the original array is LARGER than the smallest value in the squares array 1 2.20 3.3 4.4 .5 6.60 1.21 4.84 10.90 19.36 30.25 43.56 Sample run 3 (Here the largest in the original array is 4 and the snallest in the squares areay is 9. Since 4 9, it prints SMALLER in the last line) Enter 6 integers separated by a space: 3 3 3 4 3 3 original array: 3.ee 3.ee 3.08 4.8? 3.00 3.0e 9.88 9.08 9.00 16.08 9. 9.00 uared array sq The large st value n the original array is SMALLER than the smallest value in the squares array and the others like it the text original array was printed in nain and the valties 3.21 2.11 s se s e 450 s-70 were Printed m the print rw Hint for line original array: 3.21 2.11 5.30 8.09 4.90 5.70 (a i array: 3 21 2. 11 539 8-?? 4 se s. 7e

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

More Books

Students also viewed these Databases questions