Join 149,478 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,587 people online right now. Registration is fast and FREE... Join Now!
cout << "Enter the number of Resistors value you want to create: "; cin >> num; cout << endl;
ResistorsValue *cal = new ResistorsValue[num];
cal.black = 1;
for(i = 0; i < num; ++i) { cout << "Enter information for resistor number" << i + 1 << endl;
for(colors = 0; colors < size; ++colors) { cout << "Enter color band number " << colors + 1 << ": "; cin.ignore(); cin.getline(cal[colors].ColorBand,10); }
/*num2 = 1 * pow(10, numcolor3); Value = ((numcolor1 * 10) + numcolor2) * num; // This is the equation to calculate the resistor value. */
} }
can someone help me show the out put, and how to calculate the resistor value. the equation i came up with work to calculate the resistor value, but I can't seem to get the numcolor# input
This post has been edited by NickDMax: 1 May, 2007 - 07:38 PM
This is just a quick stab at this, and it will need a lot of extra features to accommodate the two different numbers of bands possible. A profound difference is the use of command line arguments rather than a menu, but if you finish the solving everything else it will be easy to throw a menu back in there. Hopefully you will be able to start to see the switching possibilities here that will bring fuzzy data into order. The enum makes it so that the color bands can be labeled as numbers or colors and still get the same results. Hopefully it will take the confusion out of the case statements that will be needed in the getValue(str) getMulitplier(str) getTolerance(str) functions.
int main(int argc, char **argv) { if (argc != 6) { cout << "USAGE: This program requires 5 resistor color codes, it then displays the value in ohms of the resitor.\n" << "Example: " << arg[0] << " red blue green violet gray\n" << "Output -> 10000 ohms \n"; return 0; } double equation[6];
for (int i = 1; i < 6; i++) equation[i-1] = getValue( arg[i], i );
displayResults( equation ); }
double getBandValue(char *str, int location) { double temp; switch (location) { case 1: case 2: temp = getValue(str); case 3: case 4: temp = getMulitplier(str); case 5: temp = getTolerance(str); }; return temp; }
P.S. This probably won't compile very well, but a good solution to that is to make a class and place the functions, arrays and enumerator into it. (I hope that you have learned how to make classes already.)
This post has been edited by ajwsurfer: 1 May, 2007 - 09:36 PM