This extension needs a unit test. For now, run it as indicated at the end of this assignment.
So it turns out that numbers can feel things. We define a happy or sad number through this process:
For example, starting with the number 15, our process yields:
- 12 + 52 = 26
- 22 + 62 = 40
- 42 + 02 = 16
- 12 + 62 = 37
- 32 + 72 = 58
Here you can see our number has fallen into the beginning stages of depression...
In this extension you will be designing a program that uses sets to find the sad cycle of a number for an arbitrary power.
In the sadcycle package of your extensions folder, create a SadCycler class.
A long is simply twice as long as an int. I recommend using it here because some of the numbers found in higher base-sad cycles can be quite large.
I highly recommend partitioning the splitting of digits, raising to the power of base, and summing into one method. The trick here is figuring out how to treat every digit in a number as its own entity.
When you done with this extension, you must be cleared by the TA to receive credit.
- Commit and push all your work to your repository
- Fill in the form below with the relevant information
- Have a TA check your work
- The TA should check your work and then fill in his or her name
- Click OK while the TA watches
- If you request propagation, it does not happen immediately, but should be posted in the next day or so
This demo box is for extension 8.1