two dimension array, resistor color band.

Using functional decomposition, write a C++ program that will prompt user for the all the color bands of a resistor and then calculate the value of the resistor.

the first 3 bands are digits, the 4th is power of 10X and 5th is tolerance.
Here is what the picture look similar to.

http://educypedia.karadimov.info/electronics/electroniccalculatorsresistor.htm

if 1st is green (value 5)
2nd is blue (value 6)
3rd is black (value 0)
4th is orange (value 3)
5th is silver (10%)
resistor is 560 x 10^3 with 10% tolerance. or 560 Kilo-ohm with 10% tolerance


a sample program out put:
Enter color for band 1 : > green
Enter color for band 2 : > blue
Enter color for band 3 : > black
Enter color for Multiplier : > orange
Enter color for Tolerance : > silver
This resistor has 560000 ohms with 10 % tolerance.


I don't know how to approve this program. Honestly i dont really understand what it ask for. Any suggestion?

the color code is define as follow:

1
2
3
4
5
6
7
char BAND_COLOR_CODE[10][8] = {“black”,”brown”,”red”,”orange”,
                              “yellow”,”green”,”blue”,”violet”,
                               “grey”,”white”};
char MULTIPLIER_COLOR_CODE[12][8] = {“black”,”brown”,”red”,”orange”,
                               “yellow”,”green”,”blue”,”violet”,
                               “grey”,”white”,”gold”,”silver”};
char TOLERANCE_COLOR_CODE[4][8] = {”brown”,”red”,”gold”,”silver”};


Any help or suggestion?
Thank in advance.
Honestly i dont really understand what it ask for

resistors have a color band on them that are used to determine the resistance of the resistor. The color band is a code, the first three colors are digits in your example this would be 560 the fourth is a multiplier 3 which is 3 x10 which basically determines how many zeros there will be. so 3x10 is 1000. now multiply 560 x 1000 and you get 560,000, or 560 kilo-ohms (kilo being 1000). In real life the value of the color band doesn't actually match the resistance of the resistor. it just has to be close, so this is where the tolerance comes in. If a 560000 ohm resistor has a 10% tolerance then the actual value of the resistor can be 10% higher or lower than the value of the color band so 504,000 - 616000 kilo-ohms would be considered within spec
Last edited on
Topic archived. No new replies allowed.