[SOLVED] COP3514.002 Project #6-Map analysis

35.00 $

Category: Tags: , , ,
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon Map-analysis-main-xa3n3b.zip (111.5 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
🔒 Securely Powered by:
Secure Checkout
5/5 - (1 vote)

Project #6: Map analysis

Task description:

In this project, you must obtain different information about a mapped territory. The territory map is represented by a 2D matrix, and each cell in this matrix represents an area of one square mile (each side is one mile in length). These cells can be either land (L) or water (W), as illustrated in the figure below.

WWWWW WLLLL WLLLL WWLLL WWWWW

Your task is to create two files: “coast.txt” and “statistics.txt”. The file “coast.txt” must show the location of coast cells, which are land cells that share at least one side with a water cell. Coast cells must be marked with ‘Y’ and other cells with ‘N’. Please consider any space outside the mapped area as water. The coast cells for the map above are shown below.

NNNNN NYYYY NYNNY NNYYY NNNNN

Finally, the file “statistics.txt” must contain the total map area, the total land area, and the “wet perimeter” (i.e., the length of land in direct contact with the water). For the map above, the total map area is 25 square miles, the total land area is 11 square miles, and the wet perimeter is 14 miles.

Execution specification:

Your program will be run with one command-line argument, which defines the text file with the input map. For instance, a program named “a.out” will be executed as follows:

./a.out [input_file.txt]

where “input_file.txt” will be replaced with the name of the map file.

Input specification:

The map file starts with one line with two integers R and C representing the number of rows and columns in the map (1 ≤ R,C ≤ 1000). Each of the next R lines contains C characters indicating the cell type: ‘W’ for water and ‘L’ for land. You must read the input from the file indicated as a command-line argument!

Output specification:

For the file “coast.txt”, print R lines, each containing C characters indicating if its respective cell in the input map is a coast cell or not. Use ‘Y’ to mark coast cells, and ‘N’ for any other cell. Do not forget the new-line character at the end of each row.

For the file “statistics.txt”, print three lines respectively showing the total map area, the total land area, and the wet perimeter. See the examples below to learn the expected format.

Example #1:

Command

 ./a.out maps/1.txt

Input file: maps/1.txt

Output file: coast.txt

Output file: statistics.txt

55 LLLLL LWWWL WWWWW LWWWW LLWWL

YYYYY
YNNNY
NNNNN
YNNNN
YYNNY
TOTAL AREA: 25
TOTAL LAND AREA: 11
WET PERIMETER: 28

Example #2:

Command

 ./a.out maps/2.txt

Input file: maps/2.txt

Output file: coast.txt

Output file: statistics.txt

55 WWWLL WWWLL WWWLL WWWLL WWWLL

NNNYY
NNNYY
NNNYY
NNNYY
NNNYY
TOTAL AREA: 25
TOTAL LAND AREA: 10
WET PERIMETER: 14

Example #3:

Command

 ./a.out maps/3.txt

Input file: maps/3.txt

Output file: coast.txt

Output file: statistics.txt

10 10
WWWWWWLLLL
WWWWWWLLLL
WWWWWWWLLL
LLWWWWWWLL
LLLLWWWWWL
WWWWWLLWWW
WWWWWLLLWW
WWWWWWLLWW
LLWWWWLLWW
LLLWWWLLWW
NNNNNNYYYY
NNNNNNYNNY
NNNNNNNYNY
YYNNNNNNYY
YYYYNNNNNY
NNNNNYYNNN
NNNNNYNYNN
NNNNNNYYNN
YYNNNNYYNN
YYYNNNYYNN
TOTAL AREA: 100
TOTAL LAND AREA: 36
WET PERIMETER: 56

1 file · 111.5 KB

  • Map-analysis-main-xa3n3b.zip 111.5 KB