Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this task you will write a program in MARIE assembly language, to work out if a given year is leap year or not. Leap

 In this task you will write a program in MARIE assembly language, to work out if a given year is leap year or not. Leap years are those that are divisible by 4, except the years that are divisible by 100. But the centurial years are leap years if they are divisible by 400. For example 1980 is a leap year because it is divisible by 4 only, 2100 is not a leap year because it is divisible by both 4 and 100, and 2000 is a leap year because it is divisible by 400. 

 

The program will ask user for an input year (e.g. 1996) and work out and display a ‘1’ or ‘0’ in the output to indicate if given year is leap or not. An algorithm to determine leap year is given below (with comments). Implement this algorithm in MARIE.

if (year modulo 4 ≠ 0) / if year is not divisible by 4

then output 0 and exit / then it is a common year

else if (year modulo 100 ≠ 0) / if year is not divisible by 100

then output 1 and exit / then it is a leap year

else if (year modulo 100 ≠ 0) / if year is not divisible by 400

then output 0 and exit / then it is a common year

else output 1 and exit / otherwise it is a leap year

As you can see from the pseudo code, the modulo calculation is applied three times to get the final result.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

The length of a year is more or less 365242196 daysSo we have to subtract more o... 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

Business Communication Developing Leaders for a Networked World

Authors: Peter Cardon

2nd edition

9814714658, 978-0073403281, 73403288, 978-9814714655

More Books

Students also viewed these Biology questions

Question

Who is to blame for what happened to Kenny and why?

Answered: 1 week ago

Question

Is Ernie being used to emotionalize Keebler cookies?

Answered: 1 week ago

Question

Given the following data, construct a stem and leaf diagram:

Answered: 1 week ago