Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a C/C+ program that will determine the resistance value (in ohms or k Ohms) of a carbon or metal film resistor (ranging from 1/8
Write a C/C+ program that will determine the resistance value (in ohms or k Ohms) of a carbon or metal film resistor (ranging from 1/8 to 5 watts) when the program user inputs the three colors of the resistors color band. Your program should accept the following characters as string variable inputs for the three resistor color bands: BLACK = 'B' (0 for bands one or two and pow(10, 0) for band three) BROWN = 'b' (1 for bands one or two and pow(10, 1) for band three) RED = 'R' or 'r' (2 for bands one or two and pow(10, 2) for band three) ORANGE 'O' or 'o' (3 for bands one or two and pow(10, 3) for band three) YELLOW = 'Y' or 'y' (4 for bands one or two and pow(10, 4) for band three) GREEN = 'G' (5 for bands one or two and pow(10, 5) for band three) BLUE = 'U' or u' (6 for bands one or two an pow(10, 6) for band three) VIOLET = 'V' or 'v' (7 for bands one or two, not used in band three because the color code only includes resistors less than 100 M ohms) GRAY = 'g' (8 for bands one or two not used for band 3) WHITE = 'W' or 'w' (9 for bands one or two, not used for band three) Your code should use either switch-case statements or if - else if loops. Your program should be able to calculate the resistor value after the user enters the characters corresponding to the three colors of resistor color bands: then display the numerical value of resistance on the screen. For example, if the user enters 'o', then 'r' and finally 'b'; then the corresponding resistor value to print out would be 32 * pow(10, 1), or 320 ohms. If the user entered 'b', 'y' and 'G' then the corresponding resistor value would be 14 * pow(10, 5) or 1400000 Ohms or 14 M ohms After writing this program, test it by typing in following three color bands as inputs: Red - green-blue Yellow - grey - black White - orange - brown
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started