4:07 PM c * 61% Algorithm The following pseudocode determines whether a year is
ID: 3349552 • Letter: 4
Question
4:07 PM c * 61% Algorithm The following pseudocode determines whether a year is a leap year or a common year in the Gregorian calendar (and n the proleptic Gregorian calendar before 1582). The year variable being tested is the integer representing the number of the year in the Gregorian calendar, and the tests are arranged to dispatch the most common cases first. Care should be taken in translating mathematical integer divisibility into specific programming languages if (year is not divisible by 4) then (it is a common year) else if (year is not divisible by 100) then (i is a leap year) else if (year is not divisible by 400) then (it is a common year) else (it is a leap year) The following relational assignment statement is true if test year is a leap year and is false if test year is not a leap year Your assingment is to find a MATLAB functon for built In function. Use only one function LeapYear built In function(lest year 4)0 && (built In function(test year,100)-0 built In function(test year,400)0) Test your oode using test year 1900 and test year 2024 Make sure you only submit your code for test year 1900 Your Script ResetMATLAB Documentation 1 test year 1908 2insert a built in MATLAB function in the 3% test your code using test-year 1900 (nc 4% after pretest delete or connnent test-yea 5 you must use a specific MATLAB function s test year 2824 8 LeapYearbuilt In function test year,4) Run ScriptExplanation / Answer
function x=built_in_function(test_year,n)
if rem(test_year,n)==0
x=0;
else
x=1;
end
end
>> year=1995
year =
1995
>> leap_year=built_in_function(year,4)== 0 &&built_in_function(year,100)~=0 && built_in_function(year,400==0)
leap_year =
0
>> year=2004
year =
2004
>> leap_year=built_in_function(year,4)== 0 &&built_in_function(year,100)~=0 && built_in_function(year,400==0)
leap_year =
1
>> year=2100
year =
2100
>> leap_year=built_in_function(year,4)== 0 &&built_in_function(year,100)~=0 && built_in_function(year,400==0)
leap_year =
0
>>
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.