Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Solve the following introductory problems on strings. Write a function dayName t

ID: 3625396 • Letter: S

Question

Solve the following introductory problems on strings. Write a function dayName that consumes a parameter, day, containing the numerical value of a day in the month of September 2006. Your function should return the name of that day as a string. For example: dayName( ) should return 'Monday' You are now given a variable named days, a vector that contains the numeric values of days in the month of September 2008. Write a script that will convert each numeric value in the vector days into a string named daysofweek with the day names separated by a comma and a space.

Explanation / Answer

Part a) The structure of the function should be divided into three parts: 1. Limit of input, 2. The formula for the program, and 3. How the formula is displayed as output. First, since there are only 30 days on September, the input cannot be greater than 30 or less than 1. So, there should be a limiting part where number over 30 or less than 1 cannot be processed. Second, the formula has to process numeric input to a usable output. Since there are 7 days in a week, the remainder can be translated as the day in the week. Given that Monday is the first day of the month, we can see that the remainder of 1 translates to monday, 2 to tuesday and, 0 as sunday. Finally, the translated value can be displayed in a quite rudimentary method of comparing numerical value to the pre-assigned string of day ie. 1 corresponds to 'Monday', 2 to 'Tuesday' .... The code may look something like function [name]=dayname(day) if (day>30 | day
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote