An electronics manufacturer has called you in to make a program to decode resistor color codes. You are given a String[] code containing three elements corresponding to the first three color bands on a resistor. Return the # of Ohms the resistor represents.
The first two bands of resistors represent the value, while the third is a multiplier, as shown in the following chart:
Color: Value: Multiplier:
black 0 1
brown 1 10
red 2 100
orange 3 1,000
yellow 4 10,000
green 5 100,000
blue 6 1,000,000
violet 7 10,000,000
grey 8 100,000,000
white 9 1,000,000,000
For example if you are given { "yellow", "violet", "red" }, you would return 4700. |