C++ Project: Air Pollution

The United Nations (UN) has set forth 17 goals for sustainable development. Goal 13 is designed to “Take urgent action to combat climate change and its impacts.” The effects of climate change are being felt now, and will continue to be felt in the future unless nations take action to combat the potential sources of that change. The move towards renewable energies, as well as advances in technology for older energy sources, are examples of that change. Of particular concern is rising sea levels, which (unchecked) have the ability to devastate coastal communities and upset ecosystems.

Air pollution is one exacerbating factor in climate change. In this project, we will consider the different pollutants involved in air pollution, as well as how they are measured and categorized.

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).

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. The World Health Organization (WHO) puts the safe limit on Ozone as 100 μg/m3 (micrograms per cubic meter) for an 8-hour mean. In terms of a qualitative rating, 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 conditional selection 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.

Before you begin, it is recommend that you explore the content found in the Cascading If Statements in C++ electronic resource. This resource includes code examples, exercises, video discussions of C++ concepts, and a vocabulary list.

As you write your code, be sure to properly document your code. Consult the C++ Coding Guidelines document (provided by the instructor) for style expectations. Well-written code is easier to debug, easier to maintain over time, and easier to extend as new requirements arise. Use good design principles and design the solution before attempting to write code.

Exercise #1: Create a program called AirQuality.cpp. This program will assess the air quality of a city, based on user input of one string and one int value:

  • The locality name (e.g. “Scranton” or “Harrisburg”). This must not be blank, and can be multiple words.
  • The observed 8-hour mean level of ozone at ground level (0-500 μg/m3)

Add code to your program to prompt the user for these two input values and store the input into two local variables. Once the input is complete, echo-print the input values back to the user with descriptive messages. Here are few sample tests you can run to check if your program is working correctly; make sure your prompts match these examples:

Test Case #1

Enter the Locality Name: SCRANTON
Enter the 8-hour mean level of ozone in micrograms/cubic meter: 52

You entered SCRANTON and an 8-hour mean level of 52 micrograms/cubic meter.

Test Case #2

Enter the Locality Name: SAN BERNADINO
Enter the 8-hour mean level of ozone in micrograms/cubic meter: 161

You entered SAN BERNADINO and an 8-hour mean level of 161 micrograms/cubic meter. 

Exercise #2: Add code to your program to determine if the given city exceeds the WHO limit for Ozone (100 μg/m3). Your code should use an if statement to make this determination. Only output a message if the limit is exceeded! Here are few sample tests you can run to check if your program is working correctly:

Test Case #3

Enter the Locality Name: SCRANTON
Enter the 8-hour mean level of ozone in micrograms/cubic meter: 52

You entered SCRANTON and an 8-hour mean level of 52 micrograms/cubic meter.

Test Case #4

Enter the Locality Name: SAN BERNADINO
Enter the 8-hour mean level of ozone in micrograms/cubic meter: 161

You entered SAN BERNADINO and an 8-hour mean level of 161 micrograms/cubic meter. 
SAN BERNADINO exceeds the 8-hour mean of 100 micrograms/cubic meter.

Exercise #3: Add code to your program to rate the given city, using the six-level Ozone scale provided previously (Good, Moderate, …). your code should use a cascading if statement combined with logical operators, and there should only be one cout statement for the rating. The cout statement should come after the cascading if statement (Hint: Store the rating in a second string variable). Here are few sample tests you can run to check if your program is working correctly:

Test Case #5

Enter the Locality Name: SCRANTON
Enter the 8-hour mean level of ozone in micrograms/cubic meter: 52

You entered SCRANTON and an 8-hour mean level of 52 micrograms/cubic meter.
SCRANTON has a rating of MODERATE.

Test Case #6

Enter the Locality Name: SAN BERNADINO
Enter the 8-hour mean level of ozone in micrograms/cubic meter: 161

You entered SAN BERNADINO and an 8-hour mean level of 161 micrograms/cubic meter. 
SAN BERNADINO exceeds the 8-hour mean of 100 micrograms/cubic meter.
SAN BERNADINO has a rating of UNHEALTHY.

Your program is now complete. Please note that you should test your program with other values (of your own creation) to test out the other four potential ratings.

Deliverables

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

Powered by WordPress. Designed by WooThemes

Skip to toolbar