Need help in solving this assignment problem question ....

I know this is a last resort but i need help from people who know JAVA cause I have just been given this assignment to do in java but i can't make head or tail of it so if you guys could help me out here i would appreciate it tremendously I am being honest i am really **** at JAVA and this assignment is due in for the 16th of december 2005. And also how do yu round an interger to nultiples of 5 that is something i dont understand. Looked in text books and stuff and still nothing. I ve got the basics for calculating the average that i can do but as for the rest e.g. counting specific intergers in an array i am lost there. would really appreciate the help on this .

Aims

This assignment allows students to demonstrate the ability to write and test a java program using:

selection and repetition control constructs

arrays

methods

General

At the University of Poppleton student feedback on modules is achieved using a questionnaire. For each question students are asked to record an integer value in the range 1 to 5 with 1=Poor, 2=Fair, 3=Average, 4=Good, 5=Excellent. For each question an average mark is computed, and a summary produced showing the number of 1s, number of 2s, etc.

Task

Write a method that reads in an collection of integer scores from the keyboard, with each score in the range 1-5, output the average, rounded to 1 decimal place, and outputs the number of each score to the nearest multiple of 5.

For example, if the scores returned are {3, 4, 2, 3, 3, 3, 4, 3, 3, 3, 4, 1, 1, 4}, the average is 41/14=2.9. There are

2 scores of 1,

1 score of 2,

7 scores of 3,

4 scores of 4, and

0 scores of 5.

Taking each of these in turn:

the nearest multiple of 5 to 2 is 0,

the nearest multiple of 5 to 1 is 0,

the nearest multiple of 5 to 7 is 5,

the nearest multiple of 5 to 4 is 5, and

the nearest multiple of 5 to 0 is 0.

Hence the values output should be

0 0 5 5 0

(Rounding to the nearest multiple of 5 was employed in the most recent national Student Satisfaction Survey.)

To solve this problem you are recommended to provide the following methods:

a method that takes an array of integers and returns the average, as a floating-point number

a method that takes a floating-point number as a parameter and outputs that number rounded to one decimal place

a method that takes an array of integers as a parameter, together with a single integer, and returns the number of times the single integer appears in the array

a method that takes an integer number as a parameter and outputs that number rounded to the nearest multiple of 5

[2755 byte] By [knightofdurhama] at [2007-10-2 7:46:09]
# 1

Don't post homework questions. Those questions are for you to work out, so that you will learn from the experience. It is OK to ask for hints, but not for entire solutions.

-- [url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url] by Eric Steven Raymond

yawmarka at 2007-7-16 21:32:07 > top of Java-index,Java Essentials,New To Java...
# 2
So, assuming you've given this a shot yourself, where did you get stuck?
yawmarka at 2007-7-16 21:32:07 > top of Java-index,Java Essentials,New To Java...
# 3
CROSS-POST http://forum.java.sun.com/thread.jspa?threadID=691967&tstart=0Where similar request for code completed thus far to be posted was made.Please do not cross-post.
yawmarka at 2007-7-16 21:32:07 > top of Java-index,Java Essentials,New To Java...
# 4
> So, assuming you've given this a shot yourself, where> did you get stuck?Here: http://forum.java.sun.com/thread.jspa?threadID=691967Crossposter.
CeciNEstPasUnProgrammeura at 2007-7-16 21:32:07 > top of Java-index,Java Essentials,New To Java...
# 5
> I have just been given this assignment...> this assignment is due in for the 16th of december 2005no sympathy from me - you cant even construct a good bullshit story
Michael_Dunna at 2007-7-16 21:32:07 > top of Java-index,Java Essentials,New To Java...
# 6

i got stuck on how to actually count out the number of intergers within my array as in the group of intergers after having calculated my average.

private static int findNum ( int[] array, int numToFind ) {

for ( int c==0; c<array.lenth; c++ ) {

if (array[c] = numToFind) {

return c;

}

}

return -1;

(the above code is just rough code i was playing with )

i was fooling around with the code and thought that myabe if i could do a number search as in search for each interger then i would be able to count it but thats where i saw myself getting complicated and hence i got stuck>

knightofdurhama at 2007-7-16 21:32:07 > top of Java-index,Java Essentials,New To Java...
# 7
Please repost that small code sample using the code formatting tags. See http://forum.java.sun.com/help.jspa?sec=formatting
knightofdurhama at 2007-7-16 21:32:07 > top of Java-index,Java Essentials,New To Java...
# 8
how about counter++ each time you find your special int while looping over the entire array?
CeciNEstPasUnProgrammeura at 2007-7-16 21:32:07 > top of Java-index,Java Essentials,New To Java...
# 9

How about storing the count in a hash map keyed on the integer value. Loop through the array, and for each integer found, create the key, value pair if the key does not exist in the map, initializing the value to one. If the key does exist, increment the value. Once you have gone through the array once, you will have a map where the keys represent the integers found, and the values represent how many times each found integer was encountered.

?{?

sharkuraa at 2007-7-16 21:32:07 > top of Java-index,Java Essentials,New To Java...
# 10
> Aims> This assignment allows students to demonstrate the> ability to write and test a java program This should be at the top of every assignment but I guess it would have absolutely zero affect on the cheaters of the world.
floundera at 2007-7-16 21:32:07 > top of Java-index,Java Essentials,New To Java...