Real World Applications:Computing Resistance
Problem
- Given single-character codes for the colored bands that mark a resistor, compute its resistance in ohms. The color codes are as follows:
Black 0, Brown 1,
Red 2, Orange 3, Yellow 4,
Green 5, Blue 6,
Violet 7,Gray 8, White 9.
- If the integer codes of the bands are (in order) c1, c2, and c3, the resistance in ohms is
R = (10*c1+c2)*10c3