Vector Operations Create ONE welldocumented main program or

Vector Operations Create ONE well-documented main program or Driver that will call three user-defined functions to solve the problems below. Burning one gallon of gasoline in your car produces 19.4 pounds of CO_2. Calculate the amount of CO_2 emitted during a year for the following vehicles, assuming they all travel 12,000 miles per year. The reported fuel efficiency numbers were extracted from the manufacturers\' websites based on the Environmental Protection Agency 2010 criteria; they are an average of the city and highway estimates. Create a user-defined function with fuel efficiency as an input vector and the amount of CO_2 emitted as the output vector. Suppress all intermediate computations using the semicolon operator.

Solution

//This class contain test function which is calculating your co2 emission per year please run this java program from //any editor you will find required table in console.

package com.list;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class Efiicency {

   public static void main(String[] args) {
       HashMap<String, ArrayList<String>> map = new HashMap<>();

       // add all vehicle records in Map

       ArrayList<String> list = new ArrayList<>();
       list.add(\"Smart car Forwo\");
       list.add(\"37\");
       map.put(\"1\", list);

       ArrayList<String> list1 = new ArrayList<>();
       list1.add(\"Civic coupe\");
       list1.add(\"29\");
       map.put(\"2\", list1);

       ArrayList<String> list2 = new ArrayList<>();
       list2.add(\"Civic Hybrid\");
       list2.add(\"43\");
       map.put(\"3\", list2);

       ArrayList<String> list3 = new ArrayList<>();
       list3.add(\"Chevrolet cobalt\");
       list3.add(\"31\");
       map.put(\"4\", list3);

       ArrayList<String> list4 = new ArrayList<>();
       list4.add(\"Toyota Prius\");
       list4.add(\"48\");
       map.put(\"5\", list4);

       ArrayList<String> list5 = new ArrayList<>();
       list5.add(\"Toyota yaris\");
       list5.add(\"32\");
       map.put(\"6\", list5);

       System.out.println(\"display map=\" + map);

       Efiicency efiicency = new Efiicency();
       efiicency.test(map);

   }

   HashMap<String, ArrayList<String>> test(HashMap<String, ArrayList<String>> map) {

       HashMap<String, ArrayList<String>> finalMap = new HashMap<>();
      
ArrayList<Data>finallist=new ArrayList<>();
  
       // one gallon gasoline produce co2 19.4 pound

       double co2pergallon = 19.4;
       double trabvelinAYearinMiles = 12000;

       Iterator it = map.entrySet().iterator();
       while (it.hasNext()) {
           Map.Entry pair = (Map.Entry) it.next();
       //   System.out.println(pair.getKey() + \" = \" + pair.getValue());
           String vehicleno = (String) pair.getKey();
           ArrayList<String> record = (ArrayList<String>) pair.getValue();
          
          
       //   System.out.println(\"vehicleno\" + vehicleno + \"record=======\" + record.get(1));

           double fuelefficencypg = Double.parseDouble(record.get(1));


           double tatalgalloninAYear = 12000 / fuelefficencypg;

           double totalCo2emmitedperyear = tatalgalloninAYear * 19.4;
          
           record.add(Double.toString(totalCo2emmitedperyear));
          
           finalMap.put(vehicleno, record);

           it.remove(); // avoids a ConcurrentModificationException
       }

       System.out.println(\"finalMap \" + finalMap);
       return finalMap;

   }
}

 Vector Operations Create ONE well-documented main program or Driver that will call three user-defined functions to solve the problems below. Burning one gallon
 Vector Operations Create ONE well-documented main program or Driver that will call three user-defined functions to solve the problems below. Burning one gallon

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site