Question: Part 1- Method practice Create a main method. In there, make an array of 100 random integers(numbers between 0 and 1000). Create a static method
Part 1- Method practice
- Create a main method. In there, make an array of 100 random integers(numbers between 0 and 1000).
- Create a static method to find average of the array. Pass the array and return the number(double) that is the average
- In the main method, call the method created in Step 2. Print out the average
- Create a method to find the min value of the array. Pass the array and return the int that is the smallest.(pass the value not the index of the value)
- In the main method call the method made in Step 4. Print out the minimum
- In the main method print out the first and last value of the array created in step 1
- Create a method to return a new array that is the reverse of the array created in step 1. Return the new array
- In the main call the method done in step 7. In the main print out the first and last value of the returned array.
- In the main method, make an array of Strings called shoppingList. It should contain {soda,corn,beans,chips,apples}
- Create another method called reverse that is an overloaded version of method created in 7. This one takes an array of Strings but the code to reverse should be the same. Remember an overloaded method has the same name, it just changes the parameters( in this case the return type is changed too). So the method header would
public static String [] reverse(String[] a)
- Make a new method called averageEvenIndexes that averages the even index values. It would return a double that represents the average of the values located in the even indexes. This means you have to sum the even index values and count how many there are. Then use these two values to compute and average and return it. Add to the main method where you call this method and print out the returned value
Output should look like
The average of array is 513.44
The minimum of array is 28
The first value is 457 , the last value is 826
After reverse, first value is 826 , the new last value is 457
In shoppingList, the first value is soda, the last value is apples
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
