Project: Air Pollution (Version 3)

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)

In this project, we will generate a report on which pollutants exceed their annual mean limits.

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 cities, based on user input of one string and five int values:

  • The locality name (e.g. “Scranton” or “Dixon City”). This must not be blank.
  • The observed average level of fine particulates (0-500 μg/m3)
  • The observed average level of coarse particulates (0-500 μg/m3)
  • The observed average level of ozone (0-500 μg/m3)
  • The observed average level of nitrogen dioxide (0-500 μg/m3)
  • The observed average level of sulfur dioxide (0-500 μg/m3)

The user input values will be stored in one string variable and one int array of size 5. Input validation must be performed for the int array values, using the method described in class. Once the input process is complete, your program should display the contents of the array in a three-column, formatted table (see the test cases). The following summary information should then be displayed after the table:

  • The number of pollutants which exceed their respective annual mean limits (Note: for Ozone, use the 8-hour mean; for Sulfur Dioxide, use the 24-hour mean).

Afterwards, 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 the input values. This process will then repeat until the user signals he/she does not wish to enter more data.

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. You must construct functions aligned with the input-process-output steps. The following function must be created and used in your program – think about how you can use it multiple times!

bool exceedsLimit(int observed_value, int annual_limit);
// Returns true if the observed_value exceeds the annual_limit, false otherwise.

Note: As per the Coding Guidelines, this function can have one and only one return statement.

Here are few sample tests you can run to check if your program is working correctly. Do NOT assume that this represents everything you need to test – test all your inputs, and be sure to make up your own test cases!

Test Case #1

Enter the Locality Name: SCRANTON
Enter the average level of fine particulates: 10
Enter the average level of coarse particulates: 33
Enter the average level of ozone: 52
Enter the average level of nitrogen dioxide: 42
Enter the average level of sulfur dioxide: 15

                      AIR POLLUTION REPORT FOR SCRANTON

    POLLUTANT                  AVERAGE LEVEL           EXCEEDS LIMIT?
    =====================      =============           ==============
    FINE PARTICULATES               10                    
    COARSE PARTICULATES             33                       *
    OZONE                           52                    
    NITROGEN DIOXIDE                42                       *
    SULFUR DIOXIDE                  15                    

There are 2 pollutants whose observed average level exceeded the annual mean limit.

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

Test Case #2

Enter the Locality Name: SAN BERNADINO
Enter the average level of fine particulates: -1
**ERROR** The value must be greater than 0. Please try again.
Enter the average level of fine particulates: 15
Enter the average level of coarse particulates: -21
**ERROR** The value must be greater than 0. Please try again.
Enter the average level of coarse particulates: 21
Enter the average level of ozone: 34
Enter the average level of nitrogen dioxide: -38
**ERROR** The value must be greater than 0. Please try again.
Enter the average level of nitrogen dioxide: 55
Enter the average level of sulfur dioxide: 19

                      AIR POLLUTION REPORT FOR SAN BERNADINO

    POLLUTANT                  AVERAGE LEVEL           EXCEEDS LIMIT?
    =====================      =============           ==============
    FINE PARTICULATES               15                       *
    COARSE PARTICULATES             21                       *
    OZONE                           34                    
    NITROGEN DIOXIDE                55                       *
    SULFUR DIOXIDE                  19                    

There are 3 pollutants whose observed average level exceeded the annual mean limit.

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

Enter the Locality Name: CARSON CITY
Enter the average level of fine particulates: 7
Enter the average level of coarse particulates: 18
Enter the average level of ozone: 44
Enter the average level of nitrogen dioxide: 16
Enter the average level of sulfur dioxide: 999
**ERROR** The value must be less than 500. Please try again.
Enter the average level of sulfur dioxide: 9

                      AIR POLLUTION REPORT FOR CARSON CITY

    POLLUTANT                  AVERAGE LEVEL           EXCEEDS LIMIT?
    =====================      =============           ==============
    FINE PARTICULATES                7                     
    COARSE PARTICULATES             18                        
    OZONE                           44                    
    NITROGEN DIOXIDE                16                        
    SULFUR DIOXIDE                   9                    

There are 0 pollutants whose observed average level exceeded the annual mean limit.

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

Deliverables

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

Powered by WordPress. Designed by WooThemes

Skip to toolbar