Due: Thursday 09/19 10:00am

Submission name: work06.rkt

For the following functions, you should look back at the quotient and remainder functions.

Write the Following Functions given the contracts.

Paste the contracts into your racket program when starting. Use define and lambda to write your functions. Include test cases with descriptive output.

;(getOnesDigit n) --> integer
;  n : non negative integer
;
;  Returns the ones digit of n
;  (getOnesDigit 7) --> 7
;  (getOnesDigit 4132) --> 2
;(removeOnesDigit n) --> integer
;  n : non negative integer
;
;  Returns n with the ones digit removed and all other digits shifted to the right.
;  If the argument given is a one digit number, returns `0`.
;  (removeOnesDigit 7) --> 0
;  (removeOnesDigit 4132) --> 413

Write contracts and the functions for the following:

getTensDigit

  • Takes in a non-negative integer.
  • Returns the tens place digit of that number.
  • If the argument given is a one digit number, returns 0.
  • You can assume only valid inputs will be used.
  • Examples:
    • (getTensDigit 7) ==> 0
    • (getTensDigit 4132) ==> 3

getNthDigit

  • Takes in two non-negative integers (n and digit).
  • Returns the number at the digit place of n.
  • If digit is 1, return the ones digit, if digit is 2 return the tens digit…
  • If n does not have a digit at the digit place, return 0
  • You can assume n is a non-negative integer.
  • You can assume digit is a positive integer.
  • Examples:
    • (getNthDigit 7 1) ==> 7
    • (getNthDigit 4132 2) ==> 3
    • (getNthDigit 4132 3) ==> 1