COMP 217 Extra Credit

Points: 10 Due Date: End of term

The resistance of a resistor is given by colored bands. The colors correspond to integer codes as given in the following table:
Color Code
Silver -2
Gold -1
Black 0
Brown 1
Red 2
Orange 3
Color Code
Yellow 4
Green 5
Blue 6
Violet 7
Gray 8
White 9
The integer codes of the bands are (in order) cl , c2, and c3 , the resistance in ohms is (10 * cl + c2)*10c3.

Write a function menu() that displays a menu of colors, prompts user to enter a color (e.g., B for black, N for brown, R for red, etc.), and returns the chosen character. Note that a few of the colors start with the same letter.

Write a function decode__char(), with a parameter to receive a color, that converts the color to corresponding numeric code and returns the code.

Write a function calc_ohms(), that takes the three code values and returns the result of the ohms calculations.

All other computation is done in main(). The functions should check for obvious error states. Things like unknown colors should result in an error message.

Deliverables:

You should turn in a listing of the program.

Notes

Think about how you will do this so you can ask questions.
ASK if you have any questions.