Ok, well Iam doing a program where I have to write a program that will read in a list of positive integers (including zero) and display some statistics regarding the integers.

Your program must store the all of the integers in an array. The maximum number of integers that you can expect is 100, however there may not necessarily be that many. Your program should allow the user to continue entering numbers until they enter a negative number or until the array is filled - whichever occurs first. If the user enters 100 numbers, you should output an message stating that the maximum size for the list has been reached, then proceed with the calculations.

After you have placed all of the integers into an array, your program should perform the following tasks, in this order:

1.Display the count of how many numbers were read


2.Display the smallest number in the array


3.Display the largest number in the array


4.Display the median (the median is the integer that is stored in the middle position of the array)


5.Display the average of all the numbers


6.Allow the user to search the array for a specified value.
◦First, ask the user to enter an integer to search for.

◦Next, search the array to determine if the given integer is in the array.

◦If the integer is not found, display a message stating that the integer is not in the list.
◦If the integer is found, then display the position number of where you found the integer. If the integer happens to be in the array more than once, then you only need to tell the first position number where you found it.

◦After performing the search, ask the user if he/she wants to search for more integers. Continue searching for numbers until the user answers "N".

•You are only allowed to use the number 100 one time in your program! You are not allowed to use the numbers 101, 99, 98, or any other number that is logically related to 100 anywhere in your program. If you need to make reference to the array size then, use the length variable to reference this rather than hard-coding numbers into your program.


•You are required to write and use at least FOUR methods in this program:

◦A method to get the numbers from the user, and place them into an array. This method should return the number of integers that it actually retrieved. The array will be passed back through a parameter (remember that the method can make changes to an array's contents and the main program will automatically see the results).

◦A method to calculate, and return, the median of the array. This will be a double value.

◦A method to calculate, and return, the average of the numbers in the array. This will be a double value.

◦A method to search for a specified value in the array. This method should return the first position number where the item is found, or return -1 if the item is not found.


•The two calculating methods, and the searching method, should not get any values from the user, and should not print anything to the screen. The main program is responsible for all of the printing.

The method which gets the numbers will need (of course) to get values from the user, but should not print anything to the screen.

I think I already have the method where I have to get the num from the user.

Help?

Recommended Answers

All 2 Replies

Please post the code you have written so far, and explain what is the problem exactly.

Ok, well I got the method on how to get the numbers from the user and put them into an array, but I dont know how to display the count of how many numbers were read and display the smallest number in the array and display the largest number in the array.

Iam pretty sure that I can get the median and the average of the numbers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.