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
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
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:

where 
If fx cell a had a concentration of
, and it blows with
, the cell C receives
, and the cells L and R receives
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
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
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
Get step-by-step solutions from verified subject matter experts
