I'm out of practice on my C++ and have kind of picked up a new hobby; it turns out that I like creating electronic devices. Particularly amplifiers and sound to light kits. Stuff like that; the problem is that determining the amount of resistance a resistor on an old creation that I'm pulling apart, or while studying someone else's work is troublesome to do on paper. The math is simple, but I'd like to create an application that can do it for me. That's why I picked up programming in the first place right? :D

Okay so here's the problem. I've created a class called Resistor and have set everything up as I should. However I'm getting a single problem (and am worried about another one occuring as soon as this one is fixed); I'm trying to create a member function that's called CalculateResistance with 4 arguments of type 'int' however the member function has to return a string and even though I've told the application to include 'string' it still tells me that 'string' is undefined.

The second problem that might occur would be one of implicit conversion. I'm unsure as to whether C++ allows this or not from 'string' to 'int' so that I get to perform the math correctly. Here is the source as well as an example of how to find the resistance of a resistor using the color coding on it.

```
#include <string>
class Resistor {
public:
Resistor();
int Bands[10];
int Multipliers[10];
int Tolerances[3];
string CalculateResistance(int, int, int, int);
};
Resistor::Resistor() {
// Black, Brown, Red, Orange, Yellow, Green, Blue, Violet, Gray, White
Bands[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
Multipliers[10] = { 0.01, 0.1, 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000 };
// Silver, Gold, None
Tolerances[3] = { 10, 5, 20 };
}
string Resistor::CalculateResistance(int Digit1, int Digit2, int Multiplier, int Tolerance) {
string x = Digit1 << Digit2;
int y = (int)x * Multiplier;
string z = "";
if (y > 999 && y < 999999) {
y /= 1000;
z = y << "KΩ" << Tolerances[Tolerance];
return z;
}
else if (y > 999999 && y < 999999999) {
y /= 1000000;
z = y << "MΩ" << Tolerances[Tolerance];
return z;
}
return "An error occured, please try again...\n";
}
```

So that's the source code I have so far. Below is an example of finding the resistance and tolerance of a resistor using the color coding on it.

Say we have a resistor with a pattern of Red, Green, Blue, Silver; the overall resistance would be 25MΩ with +- 10% tolerance. The way we find this is to use the values given to us for each and folow the math for it. The layout is Digit Digit * Multiplier.

This means that if our first band is red then our first digit is 2. If our second band is yellow then our second number is 4. Then say our third band is violet; that means our multiplier is 10,000,000. So this gives us 24 * 10,000,000 which is 240,000,000Ω or 240MΩ.

The digits, multipliers, and tolerances are provided within the constructor for the class.

Thanks for any help you can give,

Jamie

P.S. - I'm also having problems creating the initial array values if someone can help with that. As I stated I'm very much out of practice.