Question: Please explain each line of code: Please explain each line of this code: Answer: function k=how_much_new_snow() k= round(0 + (10).*rand(1,1)); end function k1=odd(val) if mod(val,2)==0
Please explain each line of code:


Please explain each line of this code:
Answer:
function k=how_much_new_snow() k= round(0 + (10).*rand(1,1)); end function k1=odd(val) if mod(val,2)==0 k1=0; else k1=1; end end % Initial value count=0; snow=[0 10 4]; sz=length(snow) budget=100; for day=1:1:sz budget=budget+10; amt=how_much_new_snow() for i=1:sz snow(i)=snow(i)+amt; end if amt>0 total=0; for n=1:sz total=total+snow(n); end budget=budget+0.2*total; if odd(day)==1 for m=1:3 if odd(m)==1 snow(m)=0; end end else for m=1:sz if odd(m)==0 snow(m)=0; end end end else for m=1:sz if snow(m)>0 snow(m)=snow(m)-1; if budget>0 budget=budget-1; else count=count+1; end end end end end
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 eguals 3, the data you must maintain for the amount of snow on the roads would look something like: [0, 10, 4 l. This would mean that currently there is n (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, 10 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 removed the even roads will be plowed. All snow on a plowed road is (unless you run out of budget 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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
