To submit the assignment save the program with the usual filename. If you know how to make a zip file, create a zip file out of the folder where your program is saved. If you don't know how to make a zip file you can just send me the pde file inside the folder where your program is saved. Send the zip file or pde file as an attachment to an email. To make things easier for me please put your name and period in the subject of the email. |
Write a program that asks the user for the number of values they would like to use. Force the user to give a number between 5 and 20 (inclusive). Read that many numbers into an array declared as:
int[] nums = new int[20];It doesn't matter that some of the elements in the array may not be used. After reading all the values, find and print the mean (average) of all the numbers in the array. Print all the numbers in the array that are less than the mean with a space between each number. Print all the numbers that are larger than the mean in the same way. Do not print any that are equal to the mean. Find and print the smallest and largest values in the array.
Here is a sample run of the program:
How many numbers would you like (5-20) 25 Input must be bewteen 5 and 20 inclusive. Try again How many numbers would you like (5-20) 2 Input must be bewteen 5 and 20 inclusive. Try again How many numbers would you like (5-20) 6 Please enter # 1 of 6 10 Please enter # 2 of 6 50 Please enter # 3 of 6 30 Please enter # 4 of 6 20 Please enter # 5 of 6 40 Please enter # 6 of 6 30 The mean is 30.0 Numbers less than the mean: 10 20 Numbers greater than the mean: 50 40 The smallest number was 10 The largest number was 50 |
The format of your output should be the same as in the example. Tell the user which number they are entering as in the example.
____ 18 asks & verifies intial input (3) _____ reads elements of array (3) _____ finds mean (3) _____ prints smaller than mean elements and larger than mean elements (3) _____ prints largest and smallest (3) _____ comments and indentation (3) _____