Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

*Also, it would help to know how to implement and call the variables in main. Required Methods You must implement each of the described methods

*Also, it would help to know how to implement and call the variables in main.

image text in transcribed

image text in transcribed

Required Methods You must implement each of the described methods with method name, return type and parameters carefully checked against the specification. The post-condition is what happens to the parameters after the method executes. When parameters are specified you must use the order they are listed in. You may implement additional methods if they aid your problem-solving. You may not use Java methods that solve the entire problem for you. 1. Method name: clearArray Parameter(s): An int array Return value: Nothing. The method return type is void. Post-Condition: The array parameter has every element in the array set to 0. Example: After calling clearArray([1, 2]), the array has its elements changed to [0,0] 2. Method name: arrayToString Parameter(s): An int array Return value: A String containing a textual representation of the parameter. The return String should start with a curly brace, then have all the numbers in the array with a comma and space between numbers, and then ending with an end curly brace. Arrays.toString or its variants should not be used in this method. Post-Condition: The array parameter is not changed. Example: Calling arrayToString([1, 2]) should return "1,2]" 3. Method name: containsDuplicate Parameter(s): A String array Return value: Returns boolean true if one element of the array is equal0 to another element of the array and false otherwise. Post-Condition: The array parameter is not changed. Example: Calling containsDuplicatel[David", "Joe") should return false. Calling containsDuplicatera", "b", "a") should return true. 4. Method name: averageArrayValues Parameter(s): An int array of at least length 1. Return value: Returns a double value that is the sum of the array elements divided by the array length. The requirement of at least one value is to prevent a divide by zero possibility. Post-Condition: The array parameter is not changed. Example: Calling averageArrayValues([1,2]) should return 1.5. 5. MethodName: frequencyCount Parameter(s): An int array. The elements of the array can only be numbers from O to 9 Return value: A new int array of 10 integers. The value in the new array at index n is the number of times value n appears in the parameter array Post-Condition: The array parameter is not changed. Example: Calling frequencyCount[0,0,1,1,1,7 would return [2,3,0,0,0,0,0,1,0,0] since there are 2 zeroes and 3 ones and 1 seven, and no other digits in the parameter array 6. Method name: reverseSound Parameter(s): A double array. Return value: Returns a double array that has its elements in reversed order from the parameter array Post-Condition: The array parameter is not changed. Example: Calling reverseSound([0.1, 0.2, 0.3, 0.5]) should return a new array [O.5, 0.3, 0.2,0.1]. 7. Method name: scaleSound Parameter(s): A double array and a double value. Return value: Returns a double array that has as its elements each of the parameter array elements scaled by the second parameter Post-Condition: The array parameter is not changed. Example: Calling scaleSound([00,-0.1, 0.3], 2.0) should return a new array [00,-02, 06) Note: The play method for sounds keeps all values in the required -1.0 to 1.0 range, you do not need to test for this like you did in the Picture brightening. Parameter(s): A double array, an int specifying how many samples offset the echo starts at, and a double giving a weight to the echo. The double array will have at least as many values as the offset. Return value: A double array as long as the array parameter plus the offset parameter. The first offset samples will be the same as the first offset samples as the parameter array. The last offset samples will be the same as the last offset samples from the parameter array scaled by the weight parameter. The middle samples will be the sample from the parameter array plus the sample from the parameter array back the offset amount scaled by the weight parameter. Here is the logic of it. An echo is a diminished sound delayed from bouncing off a distance object. So if you yell, I first hear your original signal. Then when the bounce comes back, I hear your original signal plus a scaled down signal from back in time. Then, when you stop, I only hear the scaled down Post-Condition: The array parameter is not changed. Example: Calling echoSound([0.1, 0.2, 0.3, 0.4], 1, 0.5) should return a new array of length 5 (the original array plus the offset). The new array is [0.1, 0.25, 0.4, 0.55, 0.2]. The 0.1 is before the echo starts and is unchanged. The 0.25 comes from 0.2(0.1 0.5). The 0.4 comes from 0.3(0.2 0.5). The 0.55 comes from 0.4+(0.3 0.5). The last value is all echo, and is 0.4 0.5. 9. Method name: smoothSoungd Parameter(s): A double array with at least 3 elements in it. Return value: Returns a double array that has as its elements a sliding average of the parameter array elements. More precisely: 1. The first and last elements of the new array are the same as the first and last elements of the parameter 2. For the other elements of the new array, for an element at index i, it is equal to the average of elements from the parameter array at indices i-1, i, and i+1. Post-Condition: The array parameter is not changed. Example: Calling smoothSound([0.0, 0.2, 0.7,0.21) should return a new array [O.0, 0.3, 0.3666..,.0.2]. When played, noise in the sound should be reduced

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

Marketing Database Analytics

Authors: Andrew D. Banasiewicz

1st Edition

0415657881, 978-0415657884

More Books

Students also viewed these Databases questions