Limited Offer Get 25% off — use code BESTW25
No AI No Plagiarism On-Time Delivery Free Revisions
Claim Now

decimal integer X from the keyboard at run time

Question Number One

Write a MARIE program that you: 

1.Read in a decimal integer X from the keyboard at run time. Display that value on the output. If  X is negative, stop the program.  

2.Read in a decimal integer d from the keyboard at run time. Display that value on the output. If  d is not positive stop the program.  Note that being not positive does not mean negative.

3. Otherwise, pass copies of these two values as arguments to a function called iDiv  ‐short for  Integer Division‐ that calculates two results:    

a. Q: the quotient when dividing X by d

b. R: the remainder after dividing X by d

c. For example:  iDiv( 13 , 5 ) results in Q=2 and R=3

Note: the function must get copies of the values X and d to operate on. Therefore, the original  values of X and d are not affected after the function returns. This is known as “Call‐by‐Value” 

4. Display the values of Q  and R on the screen 

5.Your program must repeat back to step 1. If you don’t, you lose 3 (out of 12) points of the  score. The program must only stop either  in step 1 or step 2. 

The iDiv(a, b) function repeatedly subtracts b from a, whenever a  b, to calculate Q (= the  number of times b was successfully subtracted from a ). When a eventually becomes less than b, what  is left of a is the remainder R. For example, iDiv(13, 5) works as follows: 

  • a = a‐b = 13 ‐ 5    so a is now 8 
  • a = a‐b = 8 ‐ 5    so a is now 3 
  • We cannot subtract b from a anymore, so R is 3 
  • We did the  (a=a – b) two times, so Q is 2 
  • Test your program against all possible causes of failure. For example, enter a negative X or a  zero/negative  d
  • Submit your .mas file with sufficient comments (particularly when testing a condition for being  true/false). write comments explaining what you are testing in conditional statements.
  • write comments explaining what you are testing in conditional statements.
  • choose the label names wisely. The name of a label should logically match the intended purpose of the target code segment.

The post decimal integer X from the keyboard at run time appeared first on My Assignment Online.

Plagiarism Free Assignment Help

Expert Help With This Assignment — On Your Terms

✓ Native UK, USA & Australia writers ✓ Deadline from 3 hours ✓ 100% Plagiarism-Free — Turnitin included ✓ Unlimited free revisions ✓ Free to submit — compare quotes
Scroll to Top