Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using matlab write this code and annotate each step 8) (13 Points) Note, this problem is more difficult and worth less points than the previous

Using matlab write this code and annotate each step image text in transcribed
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. (See the example on the next page.) 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 you must maintain for the amount of snow on the roads would look something like: [ 0, 10, 4]. 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_snowO, 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 be plowed, otherwise the even roads will be plowed. All snow on a plowed road is removed (unless you run 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 f 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] 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. i) 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, sum.. and odd0 functions if you choose

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database And Transact SQL

Authors: Lucy Scott

1st Edition

1974679985, 978-1974679980

Students also viewed these Databases questions

Question

Understand how "cause and effect" is established by experimentation

Answered: 1 week ago