Question: Java program: I have to simulate an ashcloud from a volcano breakout seen from above. It is made as a grid for odd n's, with

Java program:

I have to simulate an ashcloud from a volcano breakout seen from above.

It is made as a Java program: I have to simulate an ashcloud from a volcano breakout grid for odd n's, with the volcano in the middle. Every cell element contains a number which models the concentration of ash in the air. initially all values are 0.0, exept for the middle where the volcano has the initial value 1.0.

We now simulate that the air blows from north(N), south(S), east(E) or west(W). When the wind blows with strength seen from above. It is made as a grid for odd n's, between 0 and 1, the ash from each cell is transported to the sorrounding cells as demonstrated in the image below, where the wind blows from west:

with the volcano in the middle. Every cell element contains a number

where which models the concentration of ash in the air. initially all values

If fx cell a had a concentration of are 0.0, exept for the middle where the volcano has the initial, and it blows with value 1.0. We now simulate that the air blows from north(N), south(S),, the cell C receives east(E) or west(W). When the wind blows with strength between 0 and, and the cells L and R receives 1, the ash from each cell is transported to the sorrounding cells from cell A, and these values are now withdrawn from the value of cell A.

The ashes that flyes beyond the cells in the grid are ignored. So all values outside the grid are set to 0.0.

The ashconcentration of a cell is therefor the sum of the ahshes it receives from it's neighbors. In the middle, at the volcano the value is however added 1.0 because new ash emerge from the volcano.

Implement the simulation in the class AshCloud which has the constructor:

public Ashcloud(int n) to create a as demonstrated in the image below, where the wind blows from west: grid with the volcano at it's center.

Implement the public method:

public double[][] runSimulation(char dir, double f, int steps)

which simulates wind from "dir" with strength "f" in "steps" steps. The return value is a where If fx cell a had a concentration of , and it grid of the current ashconcentration (which is remembers by the class)

First index is row, second is column.

If the input for the method does not match the specifications, the program should write "Error" to system.out and terminate the program.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!