Menu
Question Index
...


Write a progarm to get map of match nearest double values from two different lists.

Input (List of double values, List of double values) Output
[500.00, 510.00, 515.00, 520.00]
[501.00, 504.00, 507.00, 511.00, 512.00, 521.00, 523.00]
{ 500.00 => 501.00, 510.00 => 511.00, 515.00 => 512.00, 520.00 => 521.00 }
[600.00, 605.00, 607.00, 608.00, 611.00]
[595.00, 597.00, 601.00, 606.00, 609.00, 610.00, 612.00]
{ 600.00 => 601.00, 605.00 => 606.00, 607.00 => 606.00, 608.00 => 609.00 , 611.00 => 610.00 }
[500.00, 510.00, 515.00, 520.00]
[500.00, 505.00, 507.00, 510.00, 512.00, 513.00, 515.00, 518.00, 520.00, 523.00]
{ 500.00 => 500.00, 510.00 => 510.00, 515.00 => 515.00 , 520.00 => 520.00 }
[]
[595.00, 597.00, 601.00, 606.00, 609.00, 610.00, 612.00]
null
[600.00, 605.00, 607.00, 608.00, 611.00]
[]
null
[]
[]
null

class MapNearestValuesFromTwoDifferentLists

{    public static void main(String s[])
    {
        ArrayList sourceList = new ArrayList();
        sourceList.add(500.00);
        sourceList.add(510.00);
        sourceList.add(515.00);
        sourceList.add(520.00);
        ArrayList destinationList = new ArrayList();
        destinationList.add(501.00);
        destinationList.add(504.00);
        destinationList.add(507.00);
        destinationList.add(511.00);
        destinationList.add(512.00);
        destinationList.add(521.00);
        destinationList.add(523.00);
        TreeMap result = matchNearestValuesFromTwoDifferentLists(sourceList, destinationList);
        System.out.println("The matched nearest values are "+result);

    }


public static void sortList(List<Double> list)
{
//Write a code here to sort the list of double values
}


public static Double getNearestValue(Double value, List<Double> list)
{
Double result = null;
//Write a code here to get the nearest for given value from list of values and assign to result.
return result;
}


public static TreeMap<Double, Double> matchNearestValuesFromTwoDifferentLists(List<Double> sourceList, List<Double> destinationList)
{
TreeMap<Double, Double> result = null;
//Write a code here to match the nearest values from the two different lists and assign to result.
return result;
}
}

Doubts

Problems

Topic: Collection Framework In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App