1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Testing in Java

Connected

Exercise

Applying TDD to reverse a number - part two

Now that you have put the requirements into code, you can go ahead and write the actual implementation! In this follow-up to the previous exercise, you can see much of the same code, including the unit test you just wrote. Your task here is to use modulo 10 (% 10) to implement the reverse() method.

Instructions

100 XP
  • Use % 10 to obtain the last digit of the original number on each iteration.
  • Discard the last digit of the original number during each iteration using / 10.