Question
Consider the following algorithm. 1. ???????? ? Input a four digit year. 2. if (???????? mod 4 = 0) { Divisible by 4 } 2.1
Consider the following algorithm. 1. ???????? ? Input a four digit year. 2. if (???????? mod 4 = 0) { Divisible by 4 } 2.1 if (???????? mod 100 = 0) { Divisible by 100 } 2.1.1 if (???????? mod 400 = 0) {Divisible by 400} 2.1.1.1 isLeapYear ? TRUE; 2.1.2 Else 2.1.2.1 isLeapYear ? FALSE; 2.1.3 End if 2.2 Else { Not divisible by 100} 2.2.1 isLeapYear ? TRUE; 2.3 End if 3. Else { Not divisible by 4 } 3.1 isLeapYear ? FALSE; 4. End if 5. Output isLeapYear a) Trace the algorithm starting with the input 1500. b) Document the changes that would need to be made to the algorithm after step 4 to output the number of days in a specific year. Make sure that you describe the changes in detail.
Question 3 [6 marks] Consider the following algorithm. 1. year - Input a four digit year 2. if (year mod 4 - 0 Divisible by 4) 2.1 if (year mod 100 = 0) { Divisible by 100, 2.1.1 if (year mod 400visible by 400) 2.1.1.1 isLeapYearStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started