Purpose: arrays, multi-dimensional arrays, and simulation techniques. The goal o
ID: 3657258 • Letter: P
Question
Purpose: arrays, multi-dimensional arrays, and simulation techniques. The goal of this exercise is to simulate the movement of an oil spill on the surface of a body of water. A number of simplifying assumptions need to be made in order for this to be practical. The surface of the water is divided into a two-dimensional grid of squares, represented by a two-dimensional array of numbers measuring the amount of oil in each square. Over time, oil moves from one square into neighboring squares by diffusion and pushed by a prevailing wind. We will assume that the wind is always blowing from west to east (left to right on the display). The simulation proceeds in a series of discrete time steps, i.e. in a for-loop with an integer time step variable. At each time step, the following rules determine the movement of oil in the simulation: E % of the oil in a square evaporates; Of the remaining oil, 10 / (10 + V) of the oil remains in the same square, where V is the wind velocity in miles per hour; Of the oil which does not evaporate and does not remain in the same square, 40% moves to the square immediately to the east, 20% moves into each of the squares to the north-east and the south-east; and 10% moves into each of the squares to the north and south. Oil moving into squares beyond the bounds of the array is lost to the simulation. At each time step, the program goes through the entire array and calculates the amount of oil in each square based on the amounts in the neighboring squares at the previous time step. To do this correctly you need two arrays - one to hold all the old values while the new values are computed, and one to hold the new values. The state of the simulation at anytime step is shown by displaying the contents of the array on the screen. To keep the display manageable, we assume that the maximum amount of oil in a square, measured in barrels, is 999.0, and only the digits to the left of the decimal point are displayed. Therefore, each square in the grid takes up 3 digits plus a space in the display, and so the maximum array size that will fit on the screen is 20 columns by 23 rows. Since it would be impractical to generate this display at each time step, the program runs for a given number of time steps and then displays the array. Initially (at time step zero), a given amount of oil is spilled into the middle square in the western-most column (middle of left edge of display), and all other squares are initialized to zero. The program inputs the following at the start of the run: # of barrels spilled (between 0.0 and 999.9, a double); wind velocity in miles per hour (between 0 and 99, an unsigned integer); evaporation rate (fraction between zero and one, a float); # of time steps to run (an unsigned integer). The program runs for the given number of steps and displays the resulting arrayExplanation / Answer
Question is not uploading ..... Please upload the question again if possible
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.