Question: Hey! so for my homework for my java class, I need to do something called an Iterations and Arrays. I already have my code, and

Hey! so for my homework for my java class, I need to do something called an "Iterations and Arrays". I already have my code, and it works perfectly, but I do not understand this next part:

1. Add a method called average( ) to the example program above. The new method will add up the items in the array and return the average back to the caller. In the process of adding each item, it also shows the progress by displaying the value of each of the items that was just added and the current sum. See Figure 5 for an example screen output.

2. Revise the main( ) method so a call to the new method is made and the results are displayed.

Here is my source code and Figure 5. Can you help me with and show/write the code for that average() question Hey! so for my homework for my java class, I needto do something called an "Iterations and Arrays". I already have my

public class IntArrayHW stuff private final int SIZE 15 private int AC] new int CSIZ EJ private int currentPosition methods public IntArrayTest /System. out.println ("length A.length); for currentPosition A length Curr Position++ ent CcurrentPosition]- (10 current Position) 5 //return do not place a return here public int search (int key for (int i A length i++) System.out.println(Ali]); if (A[i] key) return i; //for return -1 /ot found //search this is the main part public static void main(String args[]) IntArrayTest ar new Int Array Test int key Integer.parseInt (args Co]) the value to search for input from command line system out.println ("My name is ABcD-swEG."); int result ar.search (key System.out.println ("result result) if (result 1) System. out.println(key s not in the array. else System out.println(key s stored at position result THE END OF CODE

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!