top of page

Air Pollution Analyzer I Java Assignment help

Updated: Dec 28, 2021

This is a sample assignment done by Codersarts Android Experts.

Air Pollution Analyzer analyses hourly data about PM2.5 concentration of five cities in China in October, November and December in 2015. PM stands for particulate matter (also called particle pollution), which is the term for a mixture of solid particles and liquid droplets found in the air. PM2.5 is fine inhalable particles, with diameters that are generally 2.5 micro meters and smaller. Each line of the file "pollution.txt" has information about the pollution level and weather in a city at a particular hour and date. The data is from datasets.php.

The items on each line are :

  • City (one of "Beijing", "Chengdu", "Guangzhou", "shanghai" and "Shenyang")

  • Date: year (2015) - day of the year (1..365)

  • Hour: (0..23)

  • PM2.5 concentration in ug/m3 (double)

  • Humidity in percentage (double)

  • Temperature in Celsius (double)

  • For example, here are two lines from the file

shanghai 2015-321 15 15 93.8 16

Beijing 2015-332 23 270 86 -1

  • The overall design of the Air Pollution Analyzer program is provided, along with the declaration of a field to keep track of the pollution data. You have to complete the definitions of the methods that deal with the Array List containing the data. An Air Pollution class is also provided. An Air Pollution object stores information about a single pollution record - the values on a single line of the data file. The class contains a constructor for creating a new Air Pollution object and methods to access the different values. The constructor has the parameters mentioned above: city, date, hour, PM2.5, humidity, temperature.


  • Complete two methods:

Load Data

  • Loads the data from a file into a field containing an Array List of Air Pollution objects.

  • Hint: read all the lines from the file, and then take each line apart into the values needed to make a new Air Pollution object.

Find Hazardous Levels

  • Prints out all the Air Pollution objects in the Array List that have a PM2.5 concentration 300 or over.

  • Hint: see the methods in the Air Pollution class, especially get PM and to String


  • Complete the find Contrasting Cities method:

  • Compares each record in the list with every other record and finds every pair of cities that have a difference of PM2.5 concentration larger than 400, at the same hour on the same day.

  • For each pair, it should print

  • city A, city B, hour, date, difference


  • Write two methods:

  • find Daily Average(String city) method:

  • Prints the average daily PM2.5 value for each day for the given city, and also

  • Finds the longest sequence of days where the average PM2.5 is consistently above 200 ("Very unhealthy").

  • Hint: Use an array where the index corresponds to the day of the year.

  • Plot Pollution Levels:

  • Makes a line plot for the daily average PM2.5 concentration data of the five cities in the same figure.

  • You may choose different colors to represent different cities.

  • Hint: Make the find Daily Average(String city) method return the array for a given city

For Complete solution of this sample assignment, mail us on

Also, If you are looking for any kind of coding help in programming languages, Contact us for instant solution

bottom of page