Question

In: Advanced Math

The R-rule for oysters is that you should only eat them in months that contain the...

The R-rule for oysters is that you should only eat them in months that contain the letter R. Assuming that you like to get oysters on Saturday evenings with your friends write a program that uses the year as an input to determine how many times in that year you can get an oyster dinner and make a list of those dates for that year. Do this in a fully automated way and include a consideration of leap-years. In other words use logical statements to determine if the month has an R in it. Hint: my program is not that long, less than 20 lines, but it uses a separate function that I wrote called isleapyear, that is just a few lines. Also, I changed to format of datestr so that the month is fully spelled out. (Complete in MATLAB)

Solutions

Expert Solution

Required Matlab code with explanatory comments is given below:

function [notimes] = Q_eatoyster(Year)

pattern='r'; %pattern to check
months=["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
TR=contains(months,pattern);

if not(mod(Year,4)==0) || (mod(Year,100)==0 && not(mod(Year,400)==0))
    nodays=[31,28,31,30,31,30,31,31,30,31,30,31];
    notimes=sum(nodays.*TR);
else %if it is a leap year
    nodays=[31,29,31,30,31,30,31,31,30,31,30,31]; %number of days in Feb changes, no other changes
    notimes=sum(nodays.*TR);
end

Sample usages:

Hope this was helpful. Please do leave a positive rating if you liked this answer. Thanks and have a good day!


Related Solutions

Suppose you and a rival are the only producers of oysters in a town. Each morning...
Suppose you and a rival are the only producers of oysters in a town. Each morning you harvest oysters to sell in the afternoon. You both have the choice to collect 10 or 20 dozen oysters. Each dozen has a marginal cost of $10 (so the cost of 10 dozen oysters is $100). If 20 dozen oysters in total are brought to the market, they will sell for $35 each. If 30 dozen oysters in total are brought to the...
This should be done in JavaScript. The HTML file should only contain an empty main tag....
This should be done in JavaScript. The HTML file should only contain an empty main tag. All other HTML on the page should be created with JavaScript. The JavaScript file should be a separate file.   Make an empty HTML file, put an empty main tag inside the body. In your JavaScript, use querySelector to get a reference to the main tag and save it in a variable named main. Look up three good jokes and store them as separate variables...
how can you tell if lemons contain just one R-limonene and not a mixture of R...
how can you tell if lemons contain just one R-limonene and not a mixture of R and S limonene?
Create an outline of your project (1 page). The outline should only contain topic headings and...
Create an outline of your project (1 page). The outline should only contain topic headings and a brief description of what it will cover. See the link below for an APA formatted outline. Remember that your outline will be a guide as you write your paper to keep you on topic and organized. Required paragraph topics include but are not limited to: the role nutrition plays in the prevention of the disease, etiology, progression, treatment, recommended diets, nursing assessment, nursing...
Iron levels follow a normal distribution and you can easily use the empirical rule with them....
Iron levels follow a normal distribution and you can easily use the empirical rule with them. consider iron levels in a population that have a mean of 15.5gdl and a standard deviation of 1.6 gdl. You are measuring the iron levels in one patient. Using the Empirical Rule give an example of an iron kevel from the patient that would be considered unusual. Describe, using the values from the Empirical Rule, how you determined that this level would be considered...
According to the "flow condition" (or Hotelling's rule), what should be true if you are extracting...
According to the "flow condition" (or Hotelling's rule), what should be true if you are extracting a nonrenewable resource (with limited supply) optimally? A. All answers are correct. B. Marginal rents will be positive in all periods. C. The present value of marginal rents should be equal in all periods. D. Marginal rents should grow at a rate that is equal to the discount rate.
As a salesperson with only six months’ experience, you are somewhat nervous about calling on an...
As a salesperson with only six months’ experience, you are somewhat nervous about calling on an important buyer who has been a purchasing agent for almost 20 years. Three minutes after you have begun your presentation, he rapidly raises his arms straight up into the air and slowly clasps his hands behind his head. He leans so far back in his chair that you think he is going to fall backward on the floor. At the same time, he crosses...
discuss arguments for and against the exclusionary rule. explain whether or not you believe we should...
discuss arguments for and against the exclusionary rule. explain whether or not you believe we should have the rule
For this step, you should draw an E-R Diagram for this dataset. To this goal, you...
For this step, you should draw an E-R Diagram for this dataset. To this goal, you should conduct the following steps: 1. Identify the entities and composite entities 2. Identify the entities’ attributes and primary key 3. Identify the relationships among the entities and between entities and composite entities 4. Specify the relationships' integrities
You are to create a small DB for a hospital. The DB should contain the information about patients and physicians.
create an entity relationship diagram.You are to create a small DB for a hospital. The DB should contain the information about patients and physicians. Attributes of physicians include physician ID (identifier), name(first and Last) and specialization. Every patient has a name (first and last) and a unique patient ID. When a patient is admitted to the hospital, the patient must be assigned a physician in charge of the admission procedure. For every admission, the date of the admission to the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT