You are required to write a Java program that calculates the standard
deviation, mean, and median of a given set of numbers. The program should take
input from the user for the array of numbers and display the calculated
statistics.
Your program should perform the following tasks:
i.
Prompt the
user to enter the number of elements in the array.
4 Marks
ii.
Accept the
user’s input for each element of the array.
5 Marks
iii.
Asssign
the functions used to calculate mean, median and standard deviation to
variables mean,median and standarddeviation
3 Marks
iv.
Display
the mean,median and standarddeviation
3 Marks
v.
Calculate
the mean (average) of the entered numbers.
4 Marks
vi.
Calculate
the median (middle value) of the entered numbers.
5 Marks
vii. Calculate the standard deviation of the
entered numbers.
6 Marks
Please follow these guidelines while writing your program:
Ø Use appropriate data types and variables to
store the user input and calculated statistics.
Ø Implement separate methods to calculate the
mean, median, and standard deviation.
Ø Handle cases where the number of elements is
less than 2 for the standard deviation calculation, and provide a suitable
error message in such cases.
Ø If the number of elements is even for
calculating the median, you should take the average of the two middle values.
Ø Sub questions i-iv should be implemented in
the main function
Ensure that your program is user-friendly, and it provides meaningful
messages to guide the user through the input process. Also, consider adding
comments to explain the logic and purpose of each part of your code.
i tried java ,i want the community to help me solve this programming question which will help me to understand the grammming more and more
Afro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1