Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You have to complete this C program using if else, else if else statements i.e. nested loops. Don't do switch case. Please please read the

You have to complete this C program using "if else, else if else statements" i.e. nested loops. Don't do switch case. Please please read the entire instruction (4 pages), the notes in the 4th page and test the program according to the 3 sample outputs given then the code will work. The sample outputs have to be exactly the same starting from the spacing between two lines to spelling and using uppercase lower case when needed. Please don't forget to write relevant comments to let me understand what you did. Use camel style for naming variables. Please no errors in outputs or declaring variables. It would be better if in places of float you could use lf(long float) and use double when needed. Already, my chegg question got wasted because of errors of this same question. So, please do it as soon as possible. write it simple so I can understand.

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

LUUUUJ_2020.pat Objective In this lab you will be writing a program to calculate and display the resistance value of two resis- tors given their colour coding, and to compute and display the series and parallel equivalent resis- tance when those two resistors are connected in such fashion. Resistor Colour Codes Resistors are painted with coloured bands that can be decoded to determine their resistance value. In this lab, you will be decoding the resistance of 4-band resistors. Figure 1 contains a chart, which is a mapping from the colour of each band to a numerical value. When these 4 values are combined, one can arrive at a resistance value and a tolerance for that resistor. page 1 4-Band-Code 560k Q 15% O 1 3 CHAR COLOR Kk Black B. b_ Brown R. Red 0.0 Orange Ee Yellow Green 0,11 Blue V v Violet YAY_Grey Ww White LL Gold SS Silver 1ST BAND 2ND BAND MULTIPLIER TOLERANCE 0 10 100 + 1% 1000 3 1KO 4 10KO 10.5% 6 6 1MO +0.25% 7 7 10MQ + 0.10% 8 8 + 0.05% 9 9 0.10 | 5% 0.010 10% Figure 1: 4-Band Resistor Colour Code Chart Given the example in the chart (the colour bands Green, Blue, Yellow, and Gold), the calculation is performed as follows. The first two bands are combined to create a 2-digit number, in this case 56 (Green = 5 and Blue = 6). This value is then multiplied by the value corresponding to the third color, in this case 10 kN (Yellow), leaving us with a resistance value of 560 kN2. Next, since resistors are not perfect, we want to know the uncertainty in the resistance value, which is also known as the tolerance. The fourth and final band contains this value. Finally, after looking up the colour gold in the tolerance column, we arrive at a value of 560 kN2 + 5%. Resistance Calculator Program Write a program, Lab3.c, that starts by prompting the user for the four colour codes of two resis- tors. The four colour codes of the first resistor will be asked sequentially, followed by the four colour codes of the second resistor. Each colour will be entered by the user as a single character, either cap- ital or lower case, according to the first column of the chart in Figure 1. Your program will then print out the full names of the four colour bands for each resistor, the cor- responding resistance value for each resistor, and the equivalent resistance if they are associated in series and in parallel. The format that you will use must follow the examples given below, in terms of the line spacing and wording. If the user enters a letter that does NOT correspond to a valid colour code, your program should catch that and present an error message, as indicated in Example 3 below. When the first error is caught, at whatever band or resistor, the program exits displaying the correct values up to that point followed by the error message. The series equivalent resistance is calculated by the sum of the two resistors. The parallel equivalent is calculated by the ratio between their product and their sum (product over sum). Sample Output Example 1: Please enter the 1st band of resistor 1: Please enter the 2nd band of resistor 1: Please enter the multiplier band of resistor 1: page 2 Please enter the tolerance band of resistor 1: Please enter the 1st band of resistor 2: Please enter the 2nd band of resistor 2: Please enter the multiplier band of resistor 2: Please enter the tolerance band of resistor 2: Colour bands for resistor 1: Green Blue Yellow Gold Colour bands for resistor 2: Green Blue Yellow Gold Value in ohms of resistor 1: 560.00 KOhms +/- 5.00% Value in ohms of resistor 2: 560.00 KOhms +/- 5.00% The Equivalent in series is 1.12 MOhms The Equivalent in parallel is 280.00 KOhms Example 2: Please enter the 1st band of resistor 1: Please enter the 2nd band of resistor 1: Please enter the multiplier band of resistor 1: Please enter the tolerance band of resistor 1: Please enter the ist band of resistor 2: Please enter the 2nd band of resistor 2: Please enter the multiplier band of resistor 2: page 3 Please enter the tolerance band of resistor 2: Colour bands for resistor 1: Black White Brown Grey Colour bands for resistor 2: Brown Black Red Gold Value in ohms of resistor 1: 90.00 Ons +/- 0.05% Value in ohms of resistor 2: 1.00 KOhms +/- 5.00% The Equivalent in series is 1.09 KOhms The Equivalent in parallel is 82.57 Ohms Example 3: Please enter the lat band of resistor 1: Please enter the 2nd band of resistor 1: Please enter the multiplier band of resistor 1: Please enter the tolerance band of resistor 1: Please enter the 1st band of resistor 2: Please enter the 2nd band of resistor 2: Please enter the multiplier band of resistor 2: Please enter the tolerance band of resistor 2: Colour bands for resistor 1: Brown Black Orange Silver Colour bands for resistor 2: page 4 Invalid colour for the 1st band of resistor 2. Exiting the program... For example 3, note that capital letters and lower case letters were used as inputs, which are valid inputs. Note also that the letter z is not a valid input, and was entered for the 1st band of the sec- ond resistor. The program exited at that point displaying an error message. Notes & Tips Note that the programs outputs the resistance in units of MOhms (when resistance is greater than or equal to 1 million Ohms), KOhms (when resistance is greater than or equal to 1 thousand Ohms. but less than 1 MOhm), or just in Ohms (when less than 1 KOhm). Also, when scanning in the characters representing the colour bands, please use scanf as follows (note the space in front of %c): scanf(" %c'', &band1)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions