Friday, May 21, 2010

Please help with this java code.?

Array Assignment





1. Using JOptionPane.showInputDialog method, ask the user to please enter an integer. The integer will represent the size of the array


2. Use the integer as a parameter to the constructor to create an integer array of size equal to the user input from 1.


3. Code a fill() method that will populate the array with random integers in the range 100 to 199. Using either


a. Math.random() or


b. The Random class and one of its methods


4. Code a method that will return the sum of the integers in the array


public long sum()


5. Code a method that will return the average of the integers in the array.


float average(…)


Make sure your average method calls the sum method


6. Code a method that will return the largest integer in the array


int max()


7. Code a method that will return the smallest integer in the array


int min()


8. Code a method that returns a copy of the array in reverse order


int[] reverse()


9. Code an evens method that returns the number of even integers in the array


int evens()


10. Code a method toString() that returns a string contains the contents of the array in a user friendly output


String toString()


11. Code a method searchInt(int x) that returns the number of times the integer x appears in the array . Ask the user for the search integer


int searchInt(int x)


12. Display, using the JOptionPane.showMessageDialog method,


a Your calculations, min, max sum , the size of the array


c. the array itself using the toString(), return value from the copyReverse method (reverse order) , number of even integers and the result from the search Int





Please comment using javadoc utility





Implement a class MyArray. Your class MyArray should include methods. The following methods which may or (may not ) need parameters or return values


1. fill() // fill the array


2. getSize() // return the size of the array


3. reverse() // return an array that is a copy of the array in reverse order


4. MyArray(int x) // constructor


5. sum(), max() min()


6. evens() average() (return a float and call sum() )


7. searchInt(int x)

Please help with this java code.?
It sounds like you need more interactive help than a forum can provide.
Reply:You have stated almost every function that you need. You simply need to put it together.





Try looking up tutuorials for each part. For example, to ask for an integer look for Java I/O (Input/Output). It's very simple, and you won't find many people who would be willing to put this code together for you.
Reply:That is going to be quite difficult. If you are still stuck with your project assignment may be you can contact a java expert live at website like http://askexpert.info/ .


No comments:

Post a Comment