Question: C++ Programming Using functional decomposition, do this task. A resistor is a circuit device designed to have a specific resistance value between its ends. Resistance

C++ Programming

Using functional decomposition, do this task.

A resistor is a circuit device designed to have a specific resistance value

between its ends. Resistance values are expressed in ohm (?) or kilo

-

ohms (k?).

Resistors are frequently marked with colored bands that encode their resistance

values, as shown below.

The first three bands are digits, the fourth is a power of ten multiplier and the

fifth is the tolerance

In the resistor above, the first band is g

reen (value 5), the second band is blue

(value 6), the third band is black ( value 0) and fourth band

the multiplier is

orange (value 3) and the fifth band is silver (value 10%).

Hence the value of this resistor is 560 x 10

3

with a 10% tolerance.

That is

560,000 ohms of 560 kilo

-

ohms with 10% tolerance.

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.

A sample program run may be like this:

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.

The color codes can either be defined as a 2-dimensional array

of char OR a 1

-

dimensional array of string.

This is an example of using a 2-

dimensional array of char:

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};

This is an example of usi

ng a 1

-

dimensional array of string:

string BAND_COLOR_CODE[10]= {black,brown,red,orange,

yellow,green,blue,violet,

grey,white};

string MULTIPLIER_COLOR_CODE[12] = {black,brown,red,orange,

yellow,green,blue,violet,

grey,white,gold,silver};

string TOLERANCE_COLOR_CODE[4] = {brown,red,gold,silver};

You can also use Vectors to implement a solution for this

problem.

Then use these tables in your work to correctly display the value of a given resistor.

Note: If you type upper case or mixture of upper cas

es and lower cases, your program should still work.

For example:

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.

Find Tollerance Band (Usually Separated) and work from other side 6200 Ohm 190 Tollerance Multiplier 1st 2nd Black Black Black Black Brown Brown Brown Brown Brown Red 2% Red Red Red Red orange rangeOrange Orange Yellow Yellow Yellow Yellow 4 Green Green Green Green Blue Blue Blue Blue Violet Violet Violet Violet Grey Grey Grey Grey White White White White Gold 0.1 Gold 5% 0.01 Silver 10% Silver Multiplier Tollerance 2nd 3rd 1st 560k Ohm 10%

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!