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 focus on the daily levels of Ozone at ground level. Ozone at ground level can be harmful to human health, causing many of the health problems previously mentioned. Ozone levels are rated according to the following scale:
Range |
Rating |
0-50 | Good |
51-100 | Moderate |
101-150 | Unhealthy (for sensitive groups) |
151-200 | Unhealthy |
201-300 | Very Unhealthy |
301-500 | Hazardous |
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 one int
value:
- The locality name (e.g. “Scranton” or “Harrisburg”). This must not be blank.
- The observed average level of ozone (0-500 μg/m3)
The user input values will be stored in two separate and parallel arrays, both of size 16. After each set of two 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 two 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 two arrays in a three-column, formatted table (see the test cases). The following summary information should then be displayed after the table:
- The locality with the highest observed average level of ozone
- The locality with the lowest observed average level of ozone
- The number of localities whose observed average level of ozone exceeded the annual mean limit
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 Case #1
Enter the Locality Name: SCRANTON Enter the average level of ozone in micrograms/cubic meter: 52 Enter more data? (0 for No, 1 for Yes): 1 Enter the Locality Name: BRIGANTINE Enter the average level of ozone in micrograms/cubic meter: 65 Enter more data? (0 for No, 1 for Yes): 1 Enter the Locality Name: PITTSBURGH Enter the average level of ozone in micrograms/cubic meter: 50 Enter more data? (0 for No, 1 for Yes): 1 Enter the Locality Name: BURLINGTON Enter the average level of ozone in micrograms/cubic meter: 40 Enter more data? (0 for No, 1 for Yes): 0 LOCALITY NAME AVERAGE OZONE RATING ============ ============= ========= SCRANTON 52 MODERATE BRIGANTINE 65 MODERATE PITTSBURGH 50 GOOD BURLINGTON 40 GOOD The locality with the highest observed average level of ozone is BRIGANTINE. The locality with the lowest observed average level of ozone is BURLINGTON. There are 0 counties whose observed average level of ozone exceeded the annual mean limit. |
Test Case #2
Enter the Locality Name: SAN BERNADINO Enter the average level of ozone in micrograms/cubic meter: 161 Enter more data? (0 for No, 1 for Yes): 1 Enter the Locality Name: MODESTO Enter the average level of ozone in micrograms/cubic meter: 61 Enter more data? (0 for No, 1 for Yes): 1 Enter the Locality Name: LAS VEGAS Enter the average level of ozone in micrograms/cubic meter: 132 Enter more data? (0 for No, 1 for Yes): 1 Enter the Locality Name: CARSON CITY Enter the average level of ozone in micrograms/cubic meter: 28 Enter more data? (0 for No, 1 for Yes): 0 LOCALITY NAME AVERAGE OZONE RATING ============ ============= ========= SAN BERNADINO 161 UNHEALTHY MODESTO 61 MODERATE LAS VEGAS 132 UNHEALTHY-SG CARSON CITY 28 GOOD The locality with the highest observed average level of ozone is SAN BERNADINO. The locality with the lowest observed average level of ozone is CARSON CITY. There are 2 counties whose observed average level of ozone exceeded the annual mean limit. |
Deliverables
See the instructor for submission instructions and due date(s).