Question
I am trying to compare an user inputed resistance and tolerance, and find the closest value from the standard EIA values which i already created
I am trying to compare an user inputed resistance and tolerance, and find the closest value from the standard EIA values which i already created in arrays. After determining the standard EIA value, i want to input that information back to the user. The information should include the Closest standard resistance, and the 4 color bands needed to make that resistance. My idea was to use the resistance to color function that has been tested to work, and then send those colors into the new function StandardRes, im which i could test band 1 + band 2 's value through the inputed tolerance range. Once it goes through the for loop from the tolerance, I thought it would set equal to one of the nominal values in the array , then i would multiply band 3 to the end of the new value. C++
using namespace std; //introduces namespace std //EIA Standard array element sizes per tolerance class const int E12 = 12; // 10% tolerance const int E24 = 24; // 5% tolerance const int E6 = 6; // 20% tolerance
const int nominalE12values[E12]={10, 12, 15, 18, 22, 27, 33, 39, 47, 56, 68, 82}; // 10% tolerance const int nominalE24values[E24]={10,11,12, 13, 15, 16, 18, 20, 22, 24, 27, 30, 33, 36, 39, 43, 47, 51, 56, 62, 68, 75, 82, 91} ; // 5% tolerance const int nominalE6values[E6]={10, 15, 22, 33, 47, 68}; // 20% tolerance
class Resistance { private: double resValuee; int tolValueee; string cband1,cband2,cband3,cband4;
public: int colorToResistancee(string,string,string,string,double&,int&); //member functions int StandardRes(string&,string&,string&,string&,double&,int&); int ResistanceToColor(double,int, string &, string &, string &, string &); void maxminResistancee(double&,double&);
int main()
*assume variable below are declared
else if(answer=="b")
{
cout> rr; cout> tt; resistor.ResistanceToColor(rr,tt,bA,bB,bC,bD); resistor.StandardRes(bA,bB,bC,bD,rr,tt); cout
int Resistance::StandardRes(string &b1 ,string &b2, string &b3, string &b4, double &resR, int &tolR) { cband1 = b1; cband2 = b2; cband3 = b3; cband4 = b4; if ( cband2 == "black" ) resValuee = 0; if ( cband2 == "brown" ) resValuee = 1; if ( cband2 == "red" ) resValuee = 2; if ( cband2 == "orange" ) resValuee = 3; if ( cband2 == "yellow" ) resValuee = 4; if ( cband2 == "green" ) resValuee = 5; if ( cband2 == "blue" ) resValuee = 6; if ( cband2 == "violet" ) resValuee = 7; if ( cband2 == "gray" ) resValuee = 8; if ( cband2 == "white" ) resValuee = 9; else return 2; if ( cband1 == "black" ); if ( cband1 == "brown" ) resValuee += 10; if ( cband1 == "red" ) resValuee += 20; if ( cband1 == "orange" ) resValuee += 30; if ( cband1 == "yellow" ) resValuee += 40; if ( cband1 == "green" ) resValuee += 50; if ( cband1 == "blue" ) resValuee += 60; if ( cband1 == "violet" ) resValuee += 70; if ( cband1 == "gray" ) resValuee += 80; if ( cband1 == "white" ) resValuee += 90; else return 1; if ( cband4 == "gold" ) { tolValueee = 5; for(int i=1 ; inominalE24values[i-1] && resValuee
here is an example of the test output that i should recieve:
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