i can see the light at the end of the tunnel after working on this thing for 6 hours strait but i am faced with a last few errors.
First here is the code: it is really long. the error statements are:
'seriesParallel' :
undeclared identifier
seriesParallel' : undeclared identifier
numberOfResistors' : undeclared identifier
numberOfResistors' : undeclared identifier
etc for all seriesParallel and numberOfResistors
is it because i used the brackets incorrectly!
i had everything up to the point of calculating equivalent resistors for series and parallel. if i cut that off, the code for calculating value from the color code is perfect. (color code from the bands on resistors)
#include <iostream>
using namespace std;
int colortonumber (char x);
int colortomultiplier (int y);
int main ()
{{{{
char bcolor, bcolor1, bcolor2, bcolorM;
int number, n, flag=0,colorOrSystem,value=0, Number,
int seriesParallel,numberOfResistors;
double value5, value6, value7, value1, value2, value3, value4;// value holders for series
double sumvalue;//results for equivalent resis values for series
double valuepara1,valuepara2,valuepara3,valuepara4, valuepara5, valuepara6, valuepara7;//value holders for parallel
double spara;//result of equivalent resistor values for parallel
cout<< "Press 1 to compute the resistor value from the color code.\n";
cout<< endl;
cout<< "Press 2 to compute the equivalent resistor value \n";
cout<< "of a system connected in a series or parallel.\n";
cin >> colorOrSystem;
if (colorOrSystem == 1){
cout << " Enter the first letter of the first,second,and third\n";
cout << " colors of your band.\n";
cout << " If it is blue enter a capitalized B, if gray then \n";
cout << " a capitalized G. For all others just enter in the first\n";
cout << " letter uncapitalized.-------->";
cout<< endl;
cin >> bcolor1 >> bcolor2 >> bcolorM;
}
Number=colortomultiplier(bcolorM);
for (n = 0; n < 3; n++)
{
if (n == 0){
bcolor = bcolor1;
}
else if( n==1){
bcolor = bcolor2;
}
number=colortonumber(bcolor);
if (number == -1)
{
cout << " Wrong entry ";
flag = 1;
break;
}
if (n == 0){
value= value + number * 10;
}
else{
value = (value + number)* Number;
}
}
if (flag == 0){
cout << " The resistance value is----->";
cout<< value;
}
if (colorOrSystem == 2){
cout << " Is your system in a series or \n";
cout << " is it in a parallel configuration?\n";
cout << endl;
cout << "Press 1 for series, 2 for parallel";
cin >> seriesParallel;
}
if (seriesParallel = 1){
cout << " How many resistors are there within the system---> \n";
cin >> numberOfResistors;
cout << endl;
}
if (numberOfResistors == 2){
cout << "Please enter in the values for the two resistors---> \n";
cin >> value1 >> value2;
sumvalue = value1+value2;
cout << "The equivalent resistor value equals-->" << sumvalue;
cout << endl;
}
else if (numberOfResistors == 3){
cout << "Please enter in the values for the three resistors-->\n";
cin >> value1 >> value2 >> value3;
sumvalue = value1+value2+value3;
cout << "The equivalent resistor value equals-->" << sumvalue;
cout << endl;
}
else if (numberOfResistors == 4){
cout << "Please enter in the values for the four resistors-->\n";
cin >> value1 >> value2 >> value3 >> value4;
sumvalue = value1+value2+value3+value4;
cout << "The equivalent resistor value equals-->" << sumvalue;
}
else if (numberOfResistors == 5){
cout << "Please enter in the values for the five resistors-->\n";
cin >> value1 >> value2 >> value3 >> value4 >> value5;
sumvalue = value1+value2+value3+value4+value5;
cout << " The equivalent resistor value equals-->" << sumvalue;
cout << endl;
}
else if (numberOfResistors == 6){
cout << " Please enter in the values for the six resistors-->\n";
cin >> value1 >> value2 >> value3 >> value4 >> value5 >> value6;
sumvalue = value1+value2+value3+value4+value5+value6;
cout << "The equivalent resistor value equals-->" << sumvalue;
cout << endl;
}
else {
cout << "Please enter in the values for the seven resistors-->\n";
cin >> value1 >> value2 >> value3 >> value4 >> value5 >> value6 >> value7;
sumvalue = value1+value2+value3+value4+value5+value6+value7;
cout << "The equivalent resistor value equals-->" << sumvalue;
}
if (seriesParallel == 2){
cout << " How many resistors are within the system? (cannot be 1) \n";
cin >> numberOfResistors;
cout << endl;
}
if (numbeOfResistors == 2){
cout << " Please enter in the values for the two resistors--> \n";
cin >> valuepara1 >> valuepara2;
spara = (valuepara1*valuepara2)/(valuepara1+valuepara2);
cout << "The equivalent resistor value equals-->" << spara;
cout << endl;
}
else if (numberOfResistors == 3){
cout << "Please enter in the values for the three resistors--> \n";
cin >> valuepara1 >> valuepara2 >> valuepara3;
spara = (valuepara1*valuepara2*valuepara3)/(valuepara1+valuepara2+valuepara3);
cout << "The equivalent resistor value equals-->" << spara;
cout << endl;
}
else if (numberOfResistors == 4) {
cout << "Please enter in the values for the four resistors--> \n";
cin >> valuepara1 >> valuepara2 >> valuepara3 >> valuepara4;
spara = (valuepara1*valuepara2*valuepara3*valuepara4)/(valuepara1+valuepara2
+valuepara3+valuepara4);
cout << "The equivalent resistor value equals-->" << spara;
cout << endl;
}
else if (numberOfResistors == 5) {
cout << " Please enter in the values for the five resistors--> \n";
cin >> valuepara1 >> valuepara2 >> valuepara3 >> valuepara4 >> valuepara5;
spara = (valuepara1*valuepara2*valuepara3*valuepara4*valuepara5)/(valuepara1+valuepara2+valuepara3+valuepara4+
valuepara5);
cout << " The equivalent resistor value equals-->" << spara;
cout << endl;
}
else if (numberOfResistors == 6) {
cout << "Please enter in the values for the six resistors--> \n";
cin >> valuepara1 >> valuepara2 >> valuepara3 >> valuepara4 >> valuepara5 >> valuepara6;
spara = (valuepara1*valuepara2*valuepara3*valuepara4*valuepara5*valuepara6)/(valuepara1+valuepara2+valuepara3+
valuepara4+valuepara5+valuepara6);
cout << " The equivalent resistor value equals-->" << spara;
cout << endl;
}
else {
cout << "Please enter in the values for the seven resistors--> \n";
cin >> valuepara1 >> valuepara2 >> valuepara3 >> valuepara4 >> valuepara5 >> valuepara6 >> valuepara7;
spara = (valuepara1*valuepara2*valuepara3*valuepara4*valuepara5*valuepara6*valuepara7)/(
valuepara1+valuepara2+valuepara3+valuepara4+valuepara5+valuepara6+valuepara7);
cout << " The equivalent resistor value equals -->" << spara;
cout <<endl;
}
cout << "\n";
return 0;
}}}}
int colortonumber (char x)
{
int xno;
switch (x)
{
case 'r':
xno = 2;
break;
case 'g':
xno=5;
break;
case 'b':
xno=1;
break;
case 'B':
xno=6;
break;
case 'o':
xno=3;
break;
case 'y':
xno=4;
break;
case 'v':
xno=7;
break;
case 'G':
xno=8;
break;
case 'w':
xno=9;
break;
default:
xno=-1;
}
return xno;
}
int colortomultiplier (int y)
{
int nka;
switch (y)
{
case 'r':
nka = 100;
break;
case 'g':
nka=100000;
break;
case 'b':
nka=10;
break;
case 'B':
nka=1000000;
break;
case 'o':
nka=1000;
break;
case 'y':
nka=10000;
break;
case 'v':
nka=10000000;
break;
case 'G':
nka=100000000;
break;
case 'w':
nka=1000000000;
break;
default:
nka=-1;
}
return nka;
}