class SpikeInterpolation {

    static double getUpperValue(double[] doubles, double val) {
        double lowestUpper = Double.MAX_VALUE;

        for (double current : doubles) {
            if (current >= val && current <= lowestUpper) {
                lowestUpper = current;
            }
        }
        if (lowestUpper == Double.MAX_VALUE) {
            throw new IllegalArgumentException("Can't find the closest max value of " + val);
        }

        return lowestUpper;
    }

}