+ 5
Challenge: Measures of Central Tendency (Ungrouped Data)
In your preferred language, write a program that returns the 'mean', 'median', and the 'mode' of any data set of numbers. The output of your results should contain the texts: The mean of the data set <list_data_set> is <mean>; The median is <median>; And the mode is <mode_or_modes_if_there_are_more_than_one_mode>. Endeavour to test your program with different data sets. God speed. [EDIT] Also if any of your results is in decimal, round it of to 2 decimal places, else return a whole number
3 ответов
+ 3
@Artem - Waoh. Nice. That's good. But one thing: Look at the EDIT part of my challenge. If any of your result is a whole number, it should output this, for instance, 5 and not 5.00. But iff it's a float/decimal, say 4.5678943564, let it be rounded off to 2 decimal places like this 4.57. You get the idea.
+ 1
Here we go
https://code.sololearn.com/ceaMCZh9I124/#cpp
+ 1
Well, I changed the code to take [EDIT] into account.
But my personal opinion it is not a good idea to mix numbers with and w/o decimal points when you show them to the user. It looks not very clearly, and I still think that in this case it is better to show whole number as fractional.