I was wondering if i could get some help trying to create a simple math formula. I recently was given an interview to work as a tier1 programmer and was asked to make a program. I made the whole thing perfectly fine but what made me fail the interview was that i need to create a math formula to convert different units of measure to other units of measure. This is easy, but what made it hard was that i needed to convert these different units of measure based off of the lengths given to me in feet. This is really bugging me because the guy said that i couldve just made one equation that couldve been used for all of the conversions to the different units of measurement. So, the current units of measurement that were given contained their orginal units of measurement and their measurement in terms of feet. The formula has to utilize the different lengths in terms of feet to do these conversions. Other wise, i wouldve got the job by just dividing and multiplying everything to get my answer. The different units of measure are as follows:
inch,.083333
fathom,6
foot,1
furlong,660
kilometer,3281.5
meter,3.2815
mile,5280
rod,16.5
yard,3
The numbers after the comma are the lengths in terms of feet for that unit of measure. I have been staring at this for hours, but i cannot figure out an equation to use for all the lengths. For those that give me help, i really do appreciate it, i am beginning to feel defeated with this. Thanks again.
"input" means the quantity which is given. "infeet" is an auxiliary variable. The "output" is the requested quantity.
$$ \text{infeet}= \begin{cases} \frac{\text{input}}{1}&, \text{ if the input is given in feet}\\ \frac{\text{input}}{0.083333}&, \text{ if the input is given in inches}\\ \frac{\text{input}}{6}&, \text{ if the input is given in fathoms}\\ \frac{\text{input}}{660}&, \text{ if the input is given in furlongs}\\ \frac{\text{input}}{3281.5}&, \text{ if the input is given in kilometers}\\ \frac{\text{input}}{3.2815}&, \text{ if the input is given in meters}\\ \frac{\text{input}}{5280}&, \text{ if the input is given in miles}\\ \frac{\text{input}}{16,5}&, \text{ if the input is given in yards}\\ \frac{\text{input}}{3}&, \text{ if the input is given in yards}\\ \end{cases} $$
$$ \text{output}= \begin{cases} \text{infeet} \times {1}&, \text{ if the output is requested in feet}\\ \text{infeet}\times {0.083333}&, \text{ if the output is requested in inches}\\ \text{infeet}\times {6}&, \text{ if the output is requested in fathoms}\\ \text{infeet}\times{660}&, \text{ if the output is requested in furlongs}\\ \text{infeet}\times{3281.5}&, \text{ if the output is requested in kilometers}\\ \text{infeet}\times{3.2815}&, \text{ if the output is requested in meters}\\ \text{infeet}\times{5280}&, \text{ if the output is requested in miles}\\ \text{infeet}\times{16,5}&, \text{ if the input is requested in yards}\\ \text{infeet}\times{3}&, \text{ if the output is requested in yards}\\ \end{cases} $$