+ 1

How do I find median rate using array in C++? PLEASE HELP.

This is what I have to do: - Add a function to get the CPI values from the user and validate that they are greater than 0. - Add an array to accumulate the computed inflation rates - Add a function that sorts the values in an array of doubles. - Add a function called findMedianRate that calculates the median inflation rate using sort above. This is what I did so far: https://code.sololearn.com/cU1naqvgocD0/#cpp (I'm stuck on the array part)

12th Sep 2018, 9:04 PM
sumaia akhand
sumaia akhand - avatar
4 Respuestas
+ 2
Hello sumaia akhand nice work you got here, and I see you're making progress, anyhow, I have a question; I noticed you changed the code, previously your plan was to utilize statically sized array limited by MAX_RATES constant, but I see you removed the MAX_RATES. So my question is; Are you allowed to use STL dynamic container e.g. vector? because if you're not allowed, the statically sized array is the way to go, but do while loop here makes it hard to use that (because input count is relative). Waiting on you ...
13th Sep 2018, 1:58 PM
Ipang
+ 2
Ipang Thank you. I'm having trouble with the function swap_array and the how to sort the array so I can Calculate the median of the inflation rate This is what I did so far: https://code.sololearn.com/cU1naqvgocD0/#cpp
13th Sep 2018, 5:46 PM
sumaia akhand
sumaia akhand - avatar
+ 2
This should be the output of the code: Expected Output: Enter the old and new consumer price indices: 238.343 238.250 Inflation rate is -0.0390204 Try again? (y or Y): y Enter the old and new consumer price indices: 238.250 237.852 Inflation rate is -0.0307116 Try again? (y or Y): y Enter the old and new consumer price indices: 237.852 238.123 Inflation rate is 0.113935 Try again? (y or Y): n Average rate is -0.0307116 Median rate is -0.0390204
13th Sep 2018, 5:50 PM
sumaia akhand
sumaia akhand - avatar