In a positional number system (such as our decimal system), the value that a digit represents depends upon its position in the number. The base of the system is the number by which the value of the digit is multiplied or divided as the digit moves from one position to another. The base further determines the number of different symbols the system employs for the digits. Throughout history, the most common bases have been 10, 20, and 60. Computing and digital electronics have given new importance to bases 2, 8, and 16.
An unusual base that has zealous advocates in the UK and the USA is base 12. The number system that uses it is known as "dozenal" or "duodecimal." Proponents of base 12 speak of its ability to represent important fractions like \(\frac{1}{3}\) exactly and claim that it simplifies mental multiplication and division. Musically-inclined advocates say it more naturally describes (Western) harmonic structure, while those in the sciences have used it to create entirely new systems of measure that they claim are more faithful to observed phenomena.
This challenge asks you to make a decimal to dozenal converter for (positive) rational numbers. If you are especially ambitious, you could gain a bit of internet fame for making a working dozenal calculator (because the first ones posted online didn't work).
Write a program that prompts the user to enter a (positive) rational number in decimal form. Output the equivalent dozenal number, to ten dozenal decimal places. You may truncate the number at ten places past the decimal rather than rounding. Do not use a library like allyourbase or baseconvert in Python or boost or GMP in C++.
There is no universally-accepted standard for the digits representing the dozenal equivalent of decimal values 10 and 11. The most convenient for programming are \(10_{10} = A_{12}\) and \(11_{10} = B_{12}\). You should use those.
When you run the program, it should look something like this:
Replits can be found here: C++ and Python.
This challenge requires prompting the user for input, using standard libraries, and a lot of string manipulations. Well done for completing it!