Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Contamination Checker General Submit all files to elearn. Make sure to name file ( s ) EXACTLY as specified - including capitalization. Do not zip

Contamination Checker
General
Submit all files to elearn. Make sure to name file(s) EXACTLY as specified - including capitalization. Do not zip or otherwise package/compress files unless told to.
Make sure your program accepts input in EXACTLY the order and format given. Do not ask for extra input or change the order of inputs.
If you want to make an expanded version of a program that and get feedback on it, email it to me or show me in class.
Slight variations in output wording/formatting are usually fine (as long as formatting isn't part of the assignment).
If you do not get the right final output, print out some evidence of the work your program did to demonstrate your progress.
Readability and maintainability of your code counts. Poor formatting, confusing variable names, unnecessarily complex code, etc... will all result in deductions to your score.
Assignment Instructions
main.cpp
This is an "old school" assignment where all your code will be in one file. I should be able to do this to build your code:
g++-g -std=c++17 main.cpp -o program.exe
Problem Details
A containment wall has been built around a leaking radioactive storage tank. Unfortunately, the wall may not have been built correctly. Anywhere two wall blocks meet at a corner, radioactive gas can seep through and contaminate the area beyond. We need to know if the leak is contained and if so, how badly contaminated the area is. A leak that reaches any border square is considered to be uncontained.
Your task is to read in the locations of the radioactive container and of all the walls (each will be represented by an row / col pair). You then should print the final map after the contamination has spread. If the situation is safe (radiation did not reach the border of the map), print out "Safe" and how many square units are contaminated. If the radiation is not contained, print out "Not Safe".
You can assume that we will always be operating on a 10x10 grid like the ones shown below.
Radiation leaks
The input for the start location will always come first as row col, followed by the locations of the walls, given as a series of numbers separated by spaces: row1 col1 row2 col2.... The list of walls will always end with with 00- do not place a wall there, that is just a signal that the input is done.
You can (and should) use a loop to get the inputs and to print the board. The "contamination", count of the affected squares, and "safe" determination should be done recursively. (No loops)
You must use parameters to pass information from one recursive call to another. No global variables allowed (constants are OK). You may not make a class that contains your functions.
A solution for the contamination and count that does not use recursion will NOT receive points.
Sample Runs
While testing your code, you should just copy and paste the long input sequence into the terminal. (Right click in terminal window to paste).
Run 1
Sample Input / Output: (User input in red)
Enter contaminated location (row col): 55
Enter wall locations (row col), followed by 00 to indicate end of input:
22324223435324546425652636465600
0123456789
0**********
1**********
2** # # # # # ***
3** # *** # ***
4** # # ** # ***
5*** # # * # ***
6**** # # ****
7**********
8**********
9**********
Not Safe
Run 2
Sample Input / Output: (User input in red)
Enter contaminated location (row col): 26
Enter wall locations (row col), followed by 00 to indicate end of input:
1516172223242527323637424344454600
0123456789
0
1 # # #
2 # # # # * #
3 # *** # #
4 # # # # #
5
6
7
8
9
Safe!
Contaminated area: 4
Run 3
Sample Input / Output: (User input in red)
Enter contaminated location (row col): 16
Enter wall locations (row col), followed by 00 to indicate end of input:
0507151725262700
0123456789
0 # * #
1 # * #
2 # # #
3
4
5
6
7
8
9
Not Safe
(Note for students: We reached the edge. That is not safe even if the rest of the map looks clean.)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Mannino Michael

5th Edition

0983332401, 978-0983332404

More Books

Students also viewed these Databases questions

Question

Explain what a feasibility analysis is and why its important.

Answered: 1 week ago