CMSC 202 - Project 1 - Urban Heat Islands PDF

Title CMSC 202 - Project 1 - Urban Heat Islands
Course Computer Science II for Majors
Institution University of Maryland Baltimore County
Pages 11
File Size 413.4 KB
File Type PDF
Total Downloads 90
Total Views 151

Summary

Download CMSC 202 - Project 1 - Urban Heat Islands PDF


Description

CMSC 202 Spring 2018 Project 1 – Urban Heat Islands Assignment: Project 1 – Urban Heat Islands Due Date: Thursday, February 22nd at 8:59pm Value: 80 points

1. Overview In this project, you will:  Practice basic C++ syntax including branching structures  Write a program that calls multiple functions  Manage a two-dimensional array  Use simple file input/output

2. Background Urban heat islands (UHI) are urban or metropolitan areas that have a significantly higher temperature than the surrounding rural areas. Generally, it is the idea that a city is warmer due to the modification of surfaces than the outskirts of the city. There are several causes of the urban heat island effect including:  More dark surfaces (think roads and dark colored buildings) which absorb more solar radiation  Denser materials that have different thermal properties (concrete or asphalt versus trees and fields)  Lack of evapotranspiration (plants introducing shade and the removal of carbon dioxide)  Buildings and other man-made structures reducing wind flow and increasing reflection Often, the weather reports just mention something like “Tonight, it will be 64°F downtown and 60°F in the suburbs.” The EPA reports that the annual mean air temperature of a city with 1 million or more people can be 1.8-5.4°F warmer than its surroundings. “In the evening, the difference can be as high as 22°F (12°C).”

CMSC 202 – Computer Science 2 for Majors

Page 1

Figure 1 shows an example of what the temperature might be for a given surface type.

Figure 1. Urban Heat Island Profile

3. Assignment Description Your assignment is to develop a grid system to model how much an urban heat island might affect the temperature of a city. We will use two-dimensional arrays to store the information. The provided grid will be 5 x 6 and will be a single character. Each character will represent one of the surface cover types illustrated in Figure 1. Table 1 shows each of the surface cover types, their one-character abbreviation, and their multiplier to the base temperature. Multiplier R

1.01

S

Rural Suburban Residential

C

Commercial

1.05

U

Urban Residential

1.04

D

Downtown

1.09

P

Park

1.02

CMSC 202 – Computer Science 2 for Majors

1.03

Page 2

F

Rural Farmland

1

Table 1. Surface Cover Types and their Multipliers Then a base temperature will be entered in degrees Fahrenheit. Finally, a second grid will be generated with the updated temperature based on the surface cover type using the multiplier in table 1. For example, if the base temperature was 80 (which would be the temperature in the rural farmland F) then the calculated temperature in the rural (R) land cover would be 80.8.

4. Requirements: This is a list of the requirements of this application. For this project, it is up to you exactly how you want to implement it. For you to earn all the points, however, you will need to meet all the defined requirements.  You must follow the coding standard as defined in the CMSC 202 coding standards (found on Blackboard under course materials). This includes comments as required.  The project must be turned in on time by the deadline listed above.  The project must be completed in C++. You may not use any libraries or data structures that we have not learned in class. Libraries we have learned include , , , , , and . You should only use namespace std.  You must use a variety of functions (at least 4) including passing parameters to those functions and returning information from those functions. At least one time, an array must be passed to a function (although you may do this more than once).  The menu must be implemented with a switch statement.  All user input must be validated. For example, if a menu allows for 1, 2, or 3 to be entered and the user enters a 4, it will re-prompt the user. However, the user is expected to always enter the correct data type. i.e. If the user is asked to enter an integer, they will. If they are asked to enter a character, they will. You do not need to worry about checking for correct data types.

CMSC 202 – Computer Science 2 for Majors

Page 3

 The name of the input file is variable. As a hint, don’t forget that the “open” command requires a c-string. If you want to convert a string to a c-string, you can use the string.c_str() function.  The easiest way to implement this project is using two-dimensional arrays (of the same size but of different data types).  Have a main menu that asks if the user wants to: o Read in a file with different land covers into a two-dimensional array. Each file will be a width of 5 with a height of 6. The land covers are not limited to the sample files, it can be any combination of R,S,C,U,D,P, or F. o Model temperatures where you calculate the temperature of that area by multiplying the base temperature by the multiplier. Display the grid with consistent columns. o Exit and include a thank you message for the user  Specific coding requirements include: o Must use at least 4 different functions. o Must pass an array to a function. o Must read in a file into a two-dimensional array. o Must use at least one switch statement. o Must use input validation (assume the data is the correct type). o Must use at least one do..while loop. o Must use constants. o Must use setw to output the calculated temperature. o Min base temp is -130 and max base temp is 134.

5. Recommendations You are free to implement this with your own functions. While not required, these are some functions that you may want to include: o Main Menu – Welcomes the user to the application and has the user choose between loading in a new file, modeling the temperatures, and exiting.

CMSC 202 – Computer Science 2 for Majors

Page 4

o Load Land Cover File – Loads in a provided file and stores input into a two-dimensional array o Print Grid – Iterates over the array and displays each of the land covers o Model Temps – Asks for the current temperature. Uses current temperatures and iterates over the array and calculates the correct temperature for each of the land covers.

6. Sample Input and Output For this project, input files are very simple. For this project, there are many possible grids and your code should work for any combination of R,S,C,U,D,P, or F land uses. The user will choose a file to load. The file will look similar to this (this is all farmland and rural land cover): F F R R R F F R R R F F R R R F F R R R F F R R R F F R R R

Three test files can be downloaded from Prof. Dixon’s data folder by navigating to your project 1 folder and typing the following command: cp /afs/umbc.edu/users/j/d/jdixon/pub/cs202/proj1/proj1_*.txt .

After you copy the test land cover files, you can type “cat proj1_test1.txt” and it should show you the entire data file. In the sample output below, user input is colored blue for clarity. After compiling and running proj1, the output would look like this: -bash-4.1$ ./proj1 Welcome to the Urban Heat Island Model What would you like to do?: 1. Load Land Cover File 2. Model Temperatures Based on Land Cover

CMSC 202 – Computer Science 2 for Majors

Page 5

3. Exit

If the user would choose 1 then the output would look like this: 1 What is the name of the file to import? test1.txt The file test1.txt was not opened What would you like to do?: 1. Load Land Cover File 2. Model Temperatures Based on Land Cover 3. Exit 1 What is the name of the file to import? proj1_test1.txt File successfully loaded F F

F F

R R

R R

R R

F

F

R

R

R

F

F

R

R

R

F

F

R

R

R

F

F

R

R

R

What would you like to do?: 1. Load Land Cover File 2. Model Temperatures Based on Land Cover 3. Exit 3 Thank you for Using the Urban Heat Island Model -bash-4.1$ CMSC 202 – Computer Science 2 for Majors

Page 6

Here is another run where we do the first modeling. -bash-4.1$ ./proj1 Welcome to the Urban Heat Island Model What would you like to do?: 1. Load Land Cover File 2. Model Temperatures Based on Land Cover 3. Exit 1 What is the name of the file to import? proj1_test2.txt File successfully loaded P

P

U

D

D

P

P

U

D

D

S

S

U

U

U

S

S

S

C

C

R F

R R

S S

C C

C C

What would you like to do?: 1. Load Land Cover File 2. Model Temperatures Based on Land Cover 3. Exit 2 What is the base temperature? 80 81.6

81.6

83.2

87.2

87.2

81.6

81.6

83.2

87.2

87.2

82.4

82.4

83.2

83.2

83.2

82.4

82.4

82.4

84.0

84.0

CMSC 202 – Computer Science 2 for Majors

Page 7

80.8

80.8

82.4

84.0

84.0

80.0

80.8

82.4

84.0

84.0

What would you like to do?: 1. Load Land Cover File 2. Model Temperatures Based on Land Cover 3. Exit 3 Thank you for Using the Urban Heat Island Model -bash-4.1$ Here are some example of input validation: -bash-4.1$ ./proj1 Welcome to the Urban Heat Island Model What would you like to do?: 1. Load Land Cover File 2. Model Temperatures Based on Land Cover 3. Exit 1 What is the name of the file to import? proj1.txt The file proj1.txt was not opened What would you like to do?: 1. Load Land Cover File 2. Model Temperatures Based on Land Cover 3. Exit 1 What is the name of the file to import? proj1_test1.txt File successfully loaded CMSC 202 – Computer Science 2 for Majors

Page 8

F

F

R

R

R

F

F

R

R

R

F

F

R

R

R

F

F

R

R

R

F

F

R

R

R

F

F

R

R

R

What would you like to do?: 1. Load Land Cover File 2. Model Temperatures Based on Land Cover 3. Exit 2 What is the base temperature? -320 What is the base temperature? 200 What is the base temperature? 100 100.0 100.0 101.0 101.0 101.0 100.0 100.0 101.0 101.0 101.0 100.0 100.0 101.0 101.0 101.0 100.0 100.0 101.0 101.0 101.0 100.0 100.0 101.0 101.0 101.0 100.0 100.0 101.0 101.0 101.0 What would you like to do?: 1. Load Land Cover File 2. Model Temperatures Based on Land Cover 3. Exit 3

CMSC 202 – Computer Science 2 for Majors

Page 9

Thank you for Using the Urban Heat Island Model -bash-4.1$

7. Compiling and Running To compile your program, enter the following command at the Linux prompt: g++ -Wall proj1.cpp -o proj1 or make proj1 This command runs the GNU C++ compiler (g++). The option -Wall instructs the compiler to be verbose in its production of warning messages; the option -o proj1 (hyphen followed by the letter "o", not the digit zero), instructs the compiler to give the executable program the name proj1. If the program compiles correctly, the executable file proj1 will be created in the current directory. At the Linux prompt, enter the command ./proj1 to run your program. It should look like the sample output provided above.

8. Completing your Project When you have completed your project, you can copy it into the submission folder. You can copy your files into the submission folder as many times as you like (before the due date). We will only grade what is in your submission folder. For this project, you should submit these files to the proj1 subdirectory: proj1.cpp — should include your implementations of the required functions. Submitting your project has two steps:

CMSC 202 – Computer Science 2 for Majors

Page 10

1.

Set up a symbolic link in your home directory to your submission folder. Execute these commands: a. cd ~ b. ln

-s /afs/umbc.edu/users/j/d/jdixon/pub/cmsc202/$USER ~/cs202proj

c. To check that the symbolic link was built successfully, you can type: i. ls ~/cs202proj ii. It should list proj1, proj1-late1, proj1-late2 through proj5-late2 2.

Copy the project files into your proj1 folder. Execute these commands: a. cd to your project 1 folder. An example might be: cd ~/202/projects/proj1 b. cp proj1.cpp ~/cs202proj/proj1

You can check to make sure that your files were successfully copied over to the submission directory by entering the command ls ~/cs202proj/proj1 You can check that your program compiles and runs in the proj1 directory, but please clean up any .o and executable files. Again, do not develop your code in this directory and you should not have the only copy of your program here.

IMPORTANT: If you want to submit the project late (after the due date), you will need to copy your files to the appropriate late folder. If you can no longer copy the files into the proj1 folder, it is because the due date has passed. You should be able to see your proj1 files but you can no longer edit or copy the files in to your proj1 folder. (They will be read only)  If it is 0-24 hours late, copy your files to ~/cs202proj/proj1-late1  If it is 24-48 hours late, copy your files to ~/cs202proj/proj1-late2  If it is after 48 hours late, it is too late to be submitted. CMSC 202 – Computer Science 2 for Majors

Page 11...


Similar Free PDFs