-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalculationManager.cs
More file actions
30 lines (24 loc) · 836 Bytes
/
Copy pathCalculationManager.cs
File metadata and controls
30 lines (24 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using Caculation.Module.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Caculation.Module.Provider
{
public class CalculationManager : ICalculation
{
public double CaculateMedianValue(IList<double?> valueList)
{
valueList = valueList.OrderBy(val => val).ToList();
int size = valueList.Count;
int mid = size / 2;
double median = (size % 2 != 0) ? (double)valueList[mid] : ((double)valueList[mid] +
(double)valueList[mid - 1]) / 2;
return median;
}
public double FindPercentageValue(double minValue, int compareValue)
{
double percentageVal = ((double)(compareValue * minValue) / 100);
return percentageVal;
}
}
}