Project: Air Pollution

Ambient (Outdoor) Pollution

Air pollution is responsible for many deaths in a given year, contributing to such things as strokes, heart disease, cancer, asthma, and other respiratory diseases. Many cities actively attempt to reduce the amount of pollutants in the air, but industrialization can make this a challenge. Government policies like the Clean Air Act have also attempted to tackle this difficult problem. Check out the following video for an example of how computing power is used to assess air quality:

Such things as automobiles, fertilizers, pesticides, energy production (e.g. coal), and agricultural production all contribute pollutants to the surrounding air. Topography can exacerbate the effects of pollutants, trapping them inside a limited area or making it easy for pollutants to settle instead of being swept away by winds (think: Los Angeles, with its basin topography, typically rated as having the “worst” air quality in the United States). The following video describes some of the more common sources of air pollution, including the science behind them:

The World Health Organization (WHO) offers the following limits for the primary elements of air pollution. Please note that μg/m3 means “micrograms per cubic meter”:

Pollutant Symbol Limit Comment
Fine Particulates PM2.5 10 μg/m3 (Annual Mean)
25 μg/m3 (24-hour Mean)
Coarse Particulates PM10 20 μg/m3 (Annual Mean)
50 μg/m3 (24-hour Mean)
Ozone O3 100 μg/m3 (8-hour Mean)
Nitrogen Dioxide NO2 40 μg/m3 (Annual Mean)
200 μg/m3 (1-hour Mean)
Sulfur Dioxide SO2 20 μg/m3 (24-hour Mean)
500 μg/m3 (10-minute Mean)

C++ Project: Assessing Air Quality

This project will provide you with an introduction to the fundamentals of one-dimensional arrays and user-defined functions in C++. In this project, you will…

  • Develop code to read data from the standard input and produce data to the standard output.
  • Write code that conforms to a programming style specified by the instructor.
  • Select and implement the appropriate control structure(s) for this problem.
  • Decompose the given problem into a sequence of single-purpose functions that are highly cohesive and loosely coupled.
  • Declare, define, and initialize one-dimensional, simple data type arrays of a fixed size.
  • Demonstrate the ability to read from and write to an arbitrary array element using array indices.
  • Demonstrate an ability to process the entire array, one element at a time, performing both read and write operations.

As always, be sure to properly document your code. Consult the C++ Coding Guidelines document for proper coding standards. Use good design principles and design the solution before attempting to write code.

Create a program called AirQuality.cpp. This program will assess the air quality of Pennsylvania counties, based on user input of one string and two double values:

  • The county name (e.g. “Adams” or “Dauphin”). This must not be blank.
  • The average amount of fine particular matter observed (0-65 μg/m3)
  • The maximum amount of fine particular matter observed (0-65 μg/m3)

The user input values will be stored in three separate and parallel arrays, all of size 16. After each set of three inputs, the user will be given a choice about whether to enter more data. If the user chooses to enter more data, he/she will again be prompted for three input values. This process will then repeat until the user signals he/she does not wish to enter more data OR the arrays become full. Once the input process is complete, your program should display the contents of the three arrays in a three-column, formatted table (see the test cases). The following summary information should then be displayed after the table:

  • The county with the highest observed average level of fine particular matter
  • The county with the lowest observed average level of fine particular matter
  • The number of counties whose observed average level of fine particular matter exceeded the annual mean limit
  • The number of counties whose observed maximum level of fine particular matter exceeded the annual mean limit

All numerical values should be precise to two decimal places. Your program should make use of multiple functions besides main() (use the input/process/output cycle as your guide). Think about how each problem actually involves more than one subproblem. At a minimum, you must construct functions aligned with the input-process-output steps. Don’t forget to validate all input, in the manner we discussed in class!

Here are few sample tests you can run to check if your program is working correctly. Test Cases #1 and #2 are using CDC data from the period 2003-2011. Test Case #3 is a nonsense case which tests boundary conditions:

Test Case #1

Enter the County Name: ADAMS
Enter the average amount of PM2.5 in micrograms/cubic meter: 13.74
Enter the maximum amount of PM2.5 in micrograms/cubic meter: 61.5

Enter more data? (0 for No, 1 for Yes): 1

Enter the County Name: CARBON
Enter the average amount of PM2.5 in micrograms/cubic meter: 12.78
Enter the maximum amount of PM2.5 in micrograms/cubic meter: 59.4

Enter more data? (0 for No, 1 for Yes): 1

Enter the County Name: COLUMBIA
Enter the average amount of PM2.5 in micrograms/cubic meter: 12.74
Enter the maximum amount of PM2.5 in micrograms/cubic meter: 62.4

Enter more data? (0 for No, 1 for Yes): 1

Enter the County Name: FULTON
Enter the average amount of PM2.5 in micrograms/cubic meter: 13.89
Enter the maximum amount of PM2.5 in micrograms/cubic meter: 59.1

Enter more data? (0 for No, 1 for Yes): 0


    COUNTY NAME     AVERAGE PM2.5         MAX PM2.5
    ===========     =============         =========
          ADAMS             13.74             61.50
         CARBON             12.78             59.40
       COLUMBIA             12.74             62.40
         FULTON             13.89             59.10

The county with the highest observed average level of PM2.5 is FULTON.
The county with the lowest observed average level of PM2.5 is COLUMBIA.
There are 4 counties whose observed average level of PM2.5 exceeded the annual mean limit.
There are 4 counties whose observed maximum level of PM2.5 exceeded the annual mean limit.

Test Case #2

Enter the County Name: SCHUYLKILL
Enter the average amount of PM2.5 in micrograms/cubic meter: 13.31
Enter the maximum amount of PM2.5 in micrograms/cubic meter: 64.7

Enter more data? (0 for No, 1 for Yes): 1

Enter the County Name: DAUPHIN
Enter the average amount of PM2.5 in micrograms/cubic meter: 13.68
Enter the maximum amount of PM2.5 in micrograms/cubic meter: 64.3

Enter more data? (0 for No, 1 for Yes): 1

Enter the County Name: BUCKS
Enter the average amount of PM2.5 in micrograms/cubic meter: 12.91
Enter the maximum amount of PM2.5 in micrograms/cubic meter: 59.6

Enter more data? (0 for No, 1 for Yes): 1

Enter the County Name: WYOMING
Enter the average amount of PM2.5 in micrograms/cubic meter: 11.75
Enter the maximum amount of PM2.5 in micrograms/cubic meter: 54.9

Enter more data? (0 for No, 1 for Yes): 1

Enter the County Name: PHILADELPHIA
Enter the average amount of PM2.5 in micrograms/cubic meter: 12.82
Enter the maximum amount of PM2.5 in micrograms/cubic meter: 60.1

Enter more data? (0 for No, 1 for Yes): 0


    COUNTY NAME     AVERAGE PM2.5         MAX PM2.5
    ===========     =============         =========
     SCHUYLKILL             13.31             64.70
        DAUPHIN             13.68             64.30
          BUCKS             12.91             59.60
        WYOMING             11.75             54.90
   PHILADELPHIA             12.82             60.10

The county with the highest observed average level of PM2.5 is DAUPHIN.
The county with the lowest observed average level of PM2.5 is WYOMING.
There are 5 counties whose observed average level of PM2.5 exceeded the annual mean limit.
There are 5 counties whose observed maximum level of PM2.5 exceeded the annual mean limit.

Test Case #3 

Enter the County Name: ALPHA
Enter the average amount of PM2.5 in micrograms/cubic meter: 12.45
Enter the maximum amount of PM2.5 in micrograms/cubic meter: 13.4

Enter more data? (0 for No, 1 for Yes): 1

Enter the County Name: BETA
Enter the average amount of PM2.5 in micrograms/cubic meter: 7.6
Enter the maximum amount of PM2.5 in micrograms/cubic meter: 12.99

Enter more data? (0 for No, 1 for Yes): 1

Enter the County Name: GAMMA
Enter the average amount of PM2.5 in micrograms/cubic meter: 12.31
Enter the maximum amount of PM2.5 in micrograms/cubic meter: 16

Enter more data? (0 for No, 1 for Yes): 1

Enter the County Name: DELTA
Enter the average amount of PM2.5 in micrograms/cubic meter: 6.9
Enter the maximum amount of PM2.5 in micrograms/cubic meter: 3.4

Enter more data? (0 for No, 1 for Yes): 1

Enter the County Name: EPSILON
Enter the average amount of PM2.5 in micrograms/cubic meter: 10.2
Enter the maximum amount of PM2.5 in micrograms/cubic meter: 11.4

Enter more data? (0 for No, 1 for Yes): 0


    COUNTY NAME     AVERAGE PM2.5         MAX PM2.5
    ===========     =============         =========
          ALPHA             12.45             13.40
           BETA              7.60             12.99
          GAMMA             12.31             16.00
          DELTA              6.90              3.40
        EPSILON             10.20             11.40

The county with the highest observed average level of PM2.5 is ALPHA.
The county with the lowest observed average level of PM2.5 is DELTA.
There are 3 counties whose observed average level of PM2.5 exceeded the annual mean limit.
There are 4 counties whose observed maximum level of PM2.5 exceeded the annual mean limit.

Deliverables

See the instructor for submission instructions and due date(s).

Powered by WordPress. Designed by WooThemes

Skip to toolbar