Menu
Question Index
...


Given the mappings of the numbers and their values, write a program to estimate a value at some other number using linear interpolation.

Input (Map, double) Output (Double)
[40.0=>170.0, 80.0=>210.0, 110.0=>300.0, 90.0=>250.0, 20.0=>150.0, 10.0=>100.0, 50.0=>190.0], 135.0 362.5
[40.0=>170.0, 80.0=>210.0, 110.0=>300.0, 90.0=>250.0, 20.0=>150.0, 10.0=>100.0, 50.0=>190.0], 9.0 95.0
[510.0=>105.0, 520.0=>110.0, 530.0=>115.0, 500.0=>100.0, 540.0=>120.0], 520.0 110.0
[15.0=>50.0, 30.0=>65.0, 90.0=>120.0, 45.0=>55.0, 60.0=>85.0, 150.0=>170.0, 100.0=>98.0], 40.0 58.33333
[15.0=>50.0, 30.0=>65.0, 90.0=>120.0, 45.0=>55.0, 60.0=>85.0, 150.0=>170.0, 100.0=>98.0], 1.0 36.03

class ComplexLinearInterpolation

{    public static void main(String s[])
    {
        Map input = new HashMap();
        input.put(10.0, 100.0);
        input.put(20.0, 150.0);
        input.put(40.0, 170.0);
        input.put(50.0, 190.0);
        input.put(80.0, 210.0);
        input.put(90.0, 250.0);
        input.put(110.0, 300.0);
        System.out.println("Estimated value is : " + estimateTheValue(input, 135.0));

    }


public static Double estimateTheValue(Map<Double, Double> input, double searchNumber) {
//Write code here to estimate the value at the given number
}

//If required, write any additional methods here
}

Doubts

Problems

Topic: Java HashMap Implementation

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App