5 string Band Resister

My program MUST allow the user to enter 3 colors and my OUTPUT of your program MUST be the resistor value and tolerance
Ex:538 x 10-2= 5.38 Ohms +/- 2%

this is what i have now.
im also trying to figure out how to let the user rerun the program if wanted.


#include <iostream>
#include <cmath>
using namespace std;

int main()
{
char C1,C2,C3,C4,M, T;
int B1, B2, B3, B4;
double Multiplier;
string Tolerance;
cout << "Enter in 4 colors: ";
cin>> C1>>C2>>C3>>C4;
B1 = firstBand(C1);
B2 = firstBand(C2);
B3 = firstBand(C3);
B4 = firstBand(C4);
Multiplier = set_Multiplier(M);
Tolerance = set_Tol(T);
cout << B1 << B2 << B3 << B4 << " " << "10 pow()" << M << T;

}

int firstBand(char C)
{
if (C == 'B')
{
return 0;
}
else if (C == 'b')
{
return 1;
}
else if (C == 'R')
{
return 2;
}
else if(C == 'O')
{
return 3;
}
else if (C == 'Y')
{
return 4;
}
else if(C == 'G')
{
return 5;
}
else if(C == 'K')
{
return 6;
}
else if (C == 'V')
{
return 7;
}
else if(C== 'E')
{
return 8;
}
else if(C== 'W')
{
return 9;
}
else if(C == 'g')
{
return 0;
}
else if(C == 'S')
{
return 0;
}
else if(C == ' ')
{
return 0;
}


}
double set_Multiplier(char M)
{
if (M = 'B')
{
return 0;
}
else if (M = 'b')
{
return 1;
}
else if (M = 'R')
{
return 2;
}
else if (M = 'O')
{
return 3;
}
else if (M = 'Y')
{
return 4;
}
else if (M = 'G')
{
return 5;
}
else if (M = 'K')
{
return 6;
}
else if (M = 'V')
{
return 7;
}
else if (M = 'E')
{
return 8;
}
else if (M = 'W')
{
return 9;
}
else if (M = 'g')
{
return -1;
}
else if (M = 'S')
{
return -2;
}
else if (M = ' ')
{
return 0;
}
}
string set_Tol(char T)
{
if(T = 'B')
{
return 0;
}
else if(T = 'b')
{
return "1";
}
else if(T ='R')
{
return "+-2";
}
else if(T = 'O')
{
return "0";
}
else if(T = 'Y')
{
return "0";
}
else if(T = 'G')
{
return "+/-0.50";
}
else if(T = 'K')
{
return "+/-0.25";
}
else if (T = 'V')
{
return "+/-0.10";
}
else if(T = 'E')
{
return "+/-0.05";
}
else if(T = 'W')
{
return "0";
}
else if(T = 'g')
{
return "+/-5";
}
else if(T = 'S')
{
return "+/-10";
}
else if(T = ' ')
{
return "+/-20";
}
}
Topic archived. No new replies allowed.