Answered step by step
Verified Expert Solution
Question
1 Approved Answer
4-Band Code 2%, 5%, 10% 4k 72 5% Color 1' Rand und and Multiplier Tolerance O 2 3 th 12 4 4 TO 6 7
4-Band Code 2%, 5%, 10% 4k 72 5% Color 1' Rand und and Multiplier Tolerance O 2 3 th 12 4 4 TO 6 7 6 7 IMO 10MO 3 IN 010 SP 5-Band Code 63k4 0.1% 0.1%, 0.25% 0.5%, 1% Figure 1: Resistor Color Code Update your Lab-1-Part-1 tool to now be one main looping program with two resistor identification functions: one for determining the color-code of a given resistor value, and one to provide the resistor value when given a color-code. 1. Open Code-Blocks and start a new console application project Copy in the contents from Lab 1 Part 1 to use as a starting point. 2. Add the following function prototypes to the top of your file in addition to Lab l's prototypes: a. void getColorBands(char*, char*, char*, char*); b. void calcResistance(char,char,char, char); 3. The source code for each of your functions should be written below your main function. Optionally, if you would like to get more practice with libraries (Part 2), you could create a Resistance Library. 4. Update the prompt(void) function: a. This function should display the Color-Code Scheme displayed in Table 1 them ask the user if they would like to convert a color-code to a resistance value or determine the color-code from a resistance value. NOTE Table 1 has two more rows and one more column than in Lab 1. To save you time, the print statements for Table 1 have been provided to you in Appendix-4 1. Description of getColorBands (char*, char*, char*, char*) function: 2. This function is to be designed to collect user input of 4 characters, aligning with the character-to- color scheme shown in Table 1. b. Instead of returning anything, this function takes 4 pointers to characters as parameters. Obtaining these characters by reference means this function can "Tetun" all 4 values of user input in one function call. Make sure to error check that the user did not input an invalid color-character. 2. Description of calcResistance (char,char,char,char) function: 2. This function should take, as parameters, 4 characters that describe the color-code of a resistor. Based on these colors, the function should determine the value of the resistor and print that to the screen b. HINT: Consider using a switch-case statement in your decryption Table 1: Resistor Color-Cods Character Scheme Character 3 Band 1"& 2 Band 0 4 Band -- 100 - 2% N R O Color Black Brown Red Orange Yellow 10 -100 1,000 *10,000 100,000 * 1,000,000 10,000,000 Green 2 3 4 5 6 7 8 9 +/- 0.5% -- 0.25% +-0.1% -0.05% B V E W D S Blue Violet Grey White Gold Silver -0.01 +-5% +/- 10% 3. Description of getResistor Colors. (int) function: 2. This function should take as a parameter, an integer value of a resistor. For the sake of simplicity, we will ignore the tolerance (4 band) and fractional multipliers of Gold and Silver in the 3 band in this step, so the integer should only be between 1-99M ohms. Make sure to error check this before proceeding. Assuming a valid integer, determine what the 3-band colors would be for this integer, using a leading-0 as necessary b. HINT: Consider making a getIntBetween function that sets a min and maximum value to retrieve values between and returns a valid integer. CHINT: Consider determining what multiplier is being used before determining what digits are present in the first two bands. You can accomplish this by counting the number of times the number can be divided by 10 before it itself is less than 100 (a two-digit number). 4. Your main function should do the following: a Call the prompt function to request user input on decryption technique. b. Collect user input for which method of conversion desired Perform the requested task d. Ask the user if they would like to try another resistor i. If yes, loop back to step A 4-Band Code 2%, 5%, 10% 4k 72 5% Color 1' Rand und and Multiplier Tolerance O 2 3 th 12 4 4 TO 6 7 6 7 IMO 10MO 3 IN 010 SP 5-Band Code 63k4 0.1% 0.1%, 0.25% 0.5%, 1% Figure 1: Resistor Color Code Update your Lab-1-Part-1 tool to now be one main looping program with two resistor identification functions: one for determining the color-code of a given resistor value, and one to provide the resistor value when given a color-code. 1. Open Code-Blocks and start a new console application project Copy in the contents from Lab 1 Part 1 to use as a starting point. 2. Add the following function prototypes to the top of your file in addition to Lab l's prototypes: a. void getColorBands(char*, char*, char*, char*); b. void calcResistance(char,char,char, char); 3. The source code for each of your functions should be written below your main function. Optionally, if you would like to get more practice with libraries (Part 2), you could create a Resistance Library. 4. Update the prompt(void) function: a. This function should display the Color-Code Scheme displayed in Table 1 them ask the user if they would like to convert a color-code to a resistance value or determine the color-code from a resistance value. NOTE Table 1 has two more rows and one more column than in Lab 1. To save you time, the print statements for Table 1 have been provided to you in Appendix-4 1. Description of getColorBands (char*, char*, char*, char*) function: 2. This function is to be designed to collect user input of 4 characters, aligning with the character-to- color scheme shown in Table 1. b. Instead of returning anything, this function takes 4 pointers to characters as parameters. Obtaining these characters by reference means this function can "Tetun" all 4 values of user input in one function call. Make sure to error check that the user did not input an invalid color-character. 2. Description of calcResistance (char,char,char,char) function: 2. This function should take, as parameters, 4 characters that describe the color-code of a resistor. Based on these colors, the function should determine the value of the resistor and print that to the screen b. HINT: Consider using a switch-case statement in your decryption Table 1: Resistor Color-Cods Character Scheme Character 3 Band 1"& 2 Band 0 4 Band -- 100 - 2% N R O Color Black Brown Red Orange Yellow 10 -100 1,000 *10,000 100,000 * 1,000,000 10,000,000 Green 2 3 4 5 6 7 8 9 +/- 0.5% -- 0.25% +-0.1% -0.05% B V E W D S Blue Violet Grey White Gold Silver -0.01 +-5% +/- 10% 3. Description of getResistor Colors. (int) function: 2. This function should take as a parameter, an integer value of a resistor. For the sake of simplicity, we will ignore the tolerance (4 band) and fractional multipliers of Gold and Silver in the 3 band in this step, so the integer should only be between 1-99M ohms. Make sure to error check this before proceeding. Assuming a valid integer, determine what the 3-band colors would be for this integer, using a leading-0 as necessary b. HINT: Consider making a getIntBetween function that sets a min and maximum value to retrieve values between and returns a valid integer. CHINT: Consider determining what multiplier is being used before determining what digits are present in the first two bands. You can accomplish this by counting the number of times the number can be divided by 10 before it itself is less than 100 (a two-digit number). 4. Your main function should do the following: a Call the prompt function to request user input on decryption technique. b. Collect user input for which method of conversion desired Perform the requested task d. Ask the user if they would like to try another resistor i. If yes, loop back to step A
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