Pure Programmer

## Project: Base Conversion

Write a program that converts an integer to any base between 2 and 16. The program should accept two arguments, the maximum number to convert and the base of conversion. The program will then print the numbers 0 to the maximum each converted to the base supplied. The conversion should take place in a separate function that takes the number to convert and the base. Be sure to test the preconditions in the conversion function with assertions.

Output
\$ javac -Xlint BaseConversion.java \$ java -ea BaseConversion 64 2 0 = 0₂ 1 = 1₂ 2 = 10₂ 3 = 11₂ 4 = 100₂ 5 = 101₂ 6 = 110₂ 7 = 111₂ 8 = 1000₂ 9 = 1001₂ ... 55 = 110111₂ 56 = 111000₂ 57 = 111001₂ 58 = 111010₂ 59 = 111011₂ 60 = 111100₂ 61 = 111101₂ 62 = 111110₂ 63 = 111111₂ 64 = 1000000₂ \$ javac -Xlint BaseConversion.java \$ java -ea BaseConversion 64 8 0 = 0₈ 1 = 1₈ 2 = 2₈ 3 = 3₈ 4 = 4₈ 5 = 5₈ 6 = 6₈ 7 = 7₈ 8 = 10₈ 9 = 11₈ ... 55 = 67₈ 56 = 70₈ 57 = 71₈ 58 = 72₈ 59 = 73₈ 60 = 74₈ 61 = 75₈ 62 = 76₈ 63 = 77₈ 64 = 100₈ \$ javac -Xlint BaseConversion.java \$ java -ea BaseConversion 64 16 0 = 0₁₆ 1 = 1₁₆ 2 = 2₁₆ 3 = 3₁₆ 4 = 4₁₆ 5 = 5₁₆ 6 = 6₁₆ 7 = 7₁₆ 8 = 8₁₆ 9 = 9₁₆ ... 55 = 37₁₆ 56 = 38₁₆ 57 = 39₁₆ 58 = 3A₁₆ 59 = 3B₁₆ 60 = 3C₁₆ 61 = 3D₁₆ 62 = 3E₁₆ 63 = 3F₁₆ 64 = 40₁₆

Solution