I just need the lines of code for this problem. They can be typed here they just
ID: 2081929 • Letter: I
Question
I just need the lines of code for this problem. They can be typed here they just have to be based in using Matlab. 8) (13 Points) Note, this problem is more difficult and worth less points than the previous problems. Make sure you have answered all previous problems satisfactorily before working on this problem Write code that tracks a city's snow removal budget during a simulated winter season of 120 days. The code must implement the following requirements. a) The amount of snow is stored for each of N roads. You may assume that N exists and contains a valid value. For example, if N equals 3 the data must maintain for the amount of snow on the roads would look something like: 0, 10, 41 This would mean that currently there is no (0) snow on road 1; 10 inches of snow on road 2: and 4 inches of snow on road 3 b) For each day you simulate, use the function how much new snow0, which will return the number of inches of snow that fell that day. It returns 0 if no snow fell c) The amount of snow that falls should be added to the amount of snow already on each road. (For example, if 6 new inches of snow fell, then the road data listed in a) above would now be: 6, 16, 101) d) On days that it snows (and only on days that it snows), plows will be sent out. If the current day is an odd day, then only the odd roads (roads with odd indexes will be plowed, otherwise the even roads will be plowed. All snow on a plowed road is removed (unless you ru out of budget see the budget section below). e) If it does not snow, then one inch of snow will melt off every road. Remember, there can be a minimum of 0 inches on any road Budget You have an initial budget of$100 g) Every day you are given $10 more h) On days that it snows, you are given emergency funds equal to 20% of the current amount of snow on all the streets. (ie: If the roads had [30, 0, 50 20 l inches of snow on them, then you would receive an extra $20 for your budget.) i) It costs $1 to remove one inch of snow from a single road j) If you run out of budget, no more snow will be cleared until the next time it snows (Keep track of the number of days that you run out of budget.) k) You may use the min0, max0, and odd0 functions if you choose.Explanation / Answer
clc;
close all;
clear all;
n = 1:1:120;
N = 5;
INI_BUD = 100;
BUD = INI_BUD;
TOTAL_SNOW = 0;
today = 0;
for day = 1:1:120
DAY_MAT = how_much_new_snow(N);
DAY_SNOW = sum(DAY_MAT);
TOTAL_SNOW = TOTAL_SNOW + DAY_MAT;
BUD = BUD + 10 + 0.2*sum(TOTAL_SNOW)
if BUD > 0
if rem(day,2)>0
for i = 1:1:N
if rem(i,2)>0
today = today + TOTAL_SNOW(i);
if today > BUD
today = today - TOTAL_SNOW(i);
break;
else
TOTAL_SNOW(i) = 0;
XYZ = 0;
end
end
if DAY_SNOW == 0 && TOTAL_SNOW(i) > 0
TOTAL_SNOW(i) = TOTAL_SNOW(i) - 1;
end
BUD = BUD - today + XYZ;
end
else
for i = 1:1:N
if rem(i,2)== 0
today = today + TOTAL_SNOW(i);
TOTAL_SNOW(i) = 0;
if today > BUD
today = today - TOTAL_SNOW(i);
XYZ = today - BUD;
break;
else
TOTAL_SNOW(i) = 0;
XYZ = 0;
end
end
if DAY_SNOW == 0 && TOTAL_SNOW(i) > 0
TOTAL_SNOW(i) = TOTAL_SNOW(i) - 1;
end
end
BUD = BUD - today + XYZ;
end
else
for i = 1:1:N
if DAY_SNOW == 0 && TOTAL_SNOW(i) > 0
TOTAL_SNOW(i) = TOTAL_SNOW(i) - 1;
end
end
end
end
function x = how_much_new_snow( N );
temp = [];
for i = 1:1:N
r = randi([0 5],1,1);
temp(i) = r(1);
end
x = temp;
end