### Pointers help

Hi fellow programmers. Here is my program thus far...
 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246`` ``````#include "Resistor.h" #include #include #include #include using namespace std; //EIA Standard array element sizes per tolerance class const int E12 = 12; const int E24 = 24; const int E48 = 48; const int E96 = 96; //EIA Standard Resistor Values //E12 10% tolerance //E24 5% tolerance //E48 2% tolerance //E96 1% tolerance //10% standard values const int nominalE12Values[E12] = { 100, 120, 150, 180, 220, 270, 330, 390, 470, 560, 680, 820}; //5% standard values const int nominalE24Values[E24] = { 100, 110, 120, 130, 150, 160, 180, 200, 220, 240, 270, 300, 330, 360, 390, 430, 470, 510, 560, 620, 680, 750, 820, 910}; //2% standard values const int nominalE48Values[E48] = { 100, 105, 110, 115, 121, 127, 133, 140, 147, 154, 162, 169, 178, 187, 196, 205, 215, 226, 237, 249, 261, 274, 287, 301, 316, 332, 348, 365, 383, 402, 422, 442, 464, 487, 511, 536, 562, 590, 619, 649, 681, 715, 750, 787, 825, 866, 909, 953}; //1% standard values const int nominalE96Values[E96] = { 100, 102, 105, 107, 110, 113, 115, 118, 121, 124, 127, 130, 133, 137, 140, 143, 147, 150, 154, 158, 162, 165, 169, 174, 178, 182, 187, 191, 196, 200, 205, 210, 215, 221, 226, 232, 237, 243, 249, 255, 261, 267, 274, 280, 287, 294, 301, 309, 316, 324, 332, 340, 348, 357, 365, 374, 383, 392, 402, 412, 422, 432, 442, 453, 464, 475, 487, 499, 511, 523, 536, 549, 562, 576, 590, 604, 619, 634, 649, 665, 681, 698, 715, 732, 750, 768, 787, 806, 825, 845, 866, 887, 909, 931, 953, 976}; void DisplayResistance(Resistor &, bool ); void EnterResistance(Resistor &, bool); void main(void) { string name; Resistor * resPtr[3]; for(int i = 0; i < 3; i++) { resPtr[i] = new Resistor(); EnterResistance(resPtr[i]); } for(int j=0; j<3; j++) { DisplayResistance(resPtr[j]); } for(int i=0; i<3, i++;) { delete resPtr[i]; } system("pause"); } // Function displays all data member values of a Resistor object void DisplayResistance(Resistor*) { //Local variables to hold Resistor data copies double nom, tol, min, max; nom = resObj.getNom(); tol = resObj.getTol(); min = nom * (1.0 - tol); max = nom * (1.0 + tol); cout << endl << "Resistor object name is " << resObj.getName() << endl; cout << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(3); cout << endl << "Nominal resistance value = " << setw(15) << nom << " ohms "; cout << endl << "Tolerance = " << setw(15) << tol * 100 << " %"; cout << endl << "Minimum Resistance = " << setw(15) << min << " ohms"; cout << endl << "Maximum Resistance = " << setw(15) << max << " ohms"; cout << endl << endl; } // Function allows user to enter new values for Resistor data members void EnterResistance(Resistor*) { //Local variables to hold Resistor data copies double nom, tol; string name; //Local variable for user data entry int nomEdit = 0; int tolEdit = 0; int powerOfTen = 0; //Valid EIA entry value check boolean bool validEIA = false; //Local loop counter int i = 0; nom = resObj.getNom(); tol = resObj.getTol(); name = resObj.getName(); cout << endl << endl; cout << "Resistor being edited: " << name << endl << endl; do { cout << "Current resistance tolerance = " << tol * 100 << " %" << endl; cout << "Valid tolerances are 1%, 2%, 5% or 10%" << endl << endl; cout << "Enter 1, 2, 5 or 10: "; cin >> tolEdit; cout << endl; } while(tolEdit != 1 && tolEdit != 2 && tolEdit != 5 && tolEdit != 10); cout << "Tolerance set to " << tolEdit << " %" << endl << endl; resObj.setTol((double)tolEdit*0.01); do { cout << "Current nomimal resistance = " << nom << " ohms" << endl; cout << "Standard 10% Resistance Values, First Three Digits" << endl << endl; if(tolEdit == 10) { for( i = 0; i < E12; i++) { if(!(i % 10)) cout << endl; cout << nominalE12Values[i] << " "; } } else if(tolEdit == 5) { for( i = 0; i < E24; i++) { if(!(i % 10)) cout << endl; cout << nominalE24Values[i] << " "; } } else if(tolEdit == 2) { for( i = 0; i < E48; i++) { if(!(i % 10)) cout << endl; cout << nominalE48Values[i] << " "; } } else { for( i = 0; i < E96; i++) { if(!(i % 10)) cout << endl; cout << nominalE96Values[i] << " "; } } cout << endl << endl << "Enter first three digits: "; cin >> nomEdit; cout << "You entered " << nomEdit << endl; validEIA = false; if(tolEdit == 10) { for( i = 0; i < E12; i++) { if(nomEdit == nominalE12Values[i]) { validEIA = true; cout << "Valid EIA value entered" << endl; } } } else if(tolEdit == 5) { for( i = 0; i < E24; i++) { if(nomEdit == nominalE24Values[i]) { validEIA = true; cout << "Valid EIA value entered" << endl; } } } else if(tolEdit == 2) { for( i = 0; i < E48; i++) { if(nomEdit == nominalE48Values[i]) { validEIA = true; cout << "Valid EIA value entered" << endl; } } } else { for( i = 0; i < E96; i++) { if(nomEdit == nominalE96Values[i]) { validEIA = true; cout << "Valid EIA value entered" << endl; } } } if (validEIA == false) { cout << "Invalid EIA value entered, try again" << endl; } } while(validEIA == false); do { cout << endl << "Enter a power of ten multiplier between -2 (0.01) and 3 (1000): "; cin >> powerOfTen; cout << "You entered " << powerOfTen << endl; } while(powerOfTen < -2 || powerOfTen > 3); resObj.setNom((double)nomEdit * pow(10.0,(double)powerOfTen)); }``````

 ``123456789101112131415161718192021222324252627`` ``````//Resistor.h #ifndef resistor_H #define resistor_H #include using namespace std; class Resistor //Names the class "Resistor". { private: double nomVal; double tolVal; string ResistorName; public: //Getter and setter functions. Resistor(); //Constructor 1 Resistor(double nom, double tol, string name); //Constructor 2 ~Resistor(); //Destructor void setNom(double n); double getNom(); void setTol(double t); double getTol(); void setName(string nm); string getName (); }; #endif ``````

 ``12345678910111213141516171819202122232425262728293031323334353637383940414243444546`` ``````//Resistor.cpp #include "Resistor.h" #include #include using namespace std; //Constructor Resistor::Resistor() { nomVal = 0; tolVal = 0; } Resistor::Resistor(double nom, double tol, string name) { nomVal = nom; tolVal = tol; ResistorName = name; } //Functions void Resistor::setNom(double nom) { nomVal=nom; } double Resistor::getNom(void) { return nomVal; } void Resistor::setTol(double tol) { tolVal=tol; } double Resistor::getTol(void) { return tolVal; } void Resistor::setName(string nm) { ResistorName=nm; } string Resistor::getName(void) { return ResistorName; } Resistor::~Resistor() //Implementation of destructor from class. {}``````
Last edited on
Here are the output errors that I'm getting.
 ```1>------ Build started: Project: wk 5, Configuration: Debug Win32 ------ 1>Build started 2/21/2013 12:06:27 AM. 1>InitializeBuildStatus: 1> Touching "Debug\wk 5.unsuccessfulbuild". 1>ClCompile: 1> ResistorMain.cpp 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(67): error C2660: 'EnterResistance' : function does not take 1 arguments 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(71): error C2660: 'DisplayResistance' : function does not take 1 arguments 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(85): error C2065: 'resObj' : undeclared identifier 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(85): error C2228: left of '.getNom' must have class/struct/union 1> type is ''unknown-type'' 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(86): error C2065: 'resObj' : undeclared identifier 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(86): error C2228: left of '.getTol' must have class/struct/union 1> type is ''unknown-type'' 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(89): error C2065: 'resObj' : undeclared identifier 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(89): error C2228: left of '.getName' must have class/struct/union 1> type is ''unknown-type'' 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(117): error C2065: 'resObj' : undeclared identifier 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(117): error C2228: left of '.getNom' must have class/struct/union 1> type is ''unknown-type'' 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(118): error C2065: 'resObj' : undeclared identifier 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(118): error C2228: left of '.getTol' must have class/struct/union 1> type is ''unknown-type'' 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(119): error C2065: 'resObj' : undeclared identifier 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(119): error C2228: left of '.getName' must have class/struct/union 1> type is ''unknown-type'' 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(134): error C2065: 'resObj' : undeclared identifier 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(134): error C2228: left of '.setTol' must have class/struct/union 1> type is ''unknown-type'' 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(245): error C2065: 'resObj' : undeclared identifier 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(245): error C2228: left of '.setNom' must have class/struct/union 1> type is ''unknown-type'' 1> 1>Build FAILED. 1> 1>Time Elapsed 00:00:01.65 ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== ```

What the heck is a class/struct/union!?
Last edited on
Ok I changed all the 'resObj' to 'resPtr' however I am still getting the same output errors...

 ```1>------ Build started: Project: wk 5, Configuration: Debug Win32 ------ 1>Build started 2/21/2013 1:11:29 AM. 1>InitializeBuildStatus: 1> Touching "Debug\wk 5.unsuccessfulbuild". 1>ClCompile: 1> ResistorMain.cpp 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(66): error C2660: 'EnterResistance' : function does not take 1 arguments 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(70): error C2660: 'DisplayResistance' : function does not take 1 arguments 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(84): error C2065: 'resPtr' : undeclared identifier 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(84): error C2228: left of '.getNom' must have class/struct/union 1> type is ''unknown-type'' 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(85): error C2065: 'resPtr' : undeclared identifier 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(85): error C2228: left of '.getTol' must have class/struct/union 1> type is ''unknown-type'' 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(88): error C2065: 'resPtr' : undeclared identifier 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(88): error C2228: left of '.getName' must have class/struct/union 1> type is ''unknown-type'' 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(116): error C2065: 'resPtr' : undeclared identifier 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(116): error C2228: left of '.getNom' must have class/struct/union 1> type is ''unknown-type'' 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(117): error C2065: 'resPtr' : undeclared identifier 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(117): error C2228: left of '.getTol' must have class/struct/union 1> type is ''unknown-type'' 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(118): error C2065: 'resPtr' : undeclared identifier 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(118): error C2228: left of '.getName' must have class/struct/union 1> type is ''unknown-type'' 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(133): error C2065: 'resPtr' : undeclared identifier 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(133): error C2228: left of '.setTol' must have class/struct/union 1> type is ''unknown-type'' 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(244): error C2065: 'resPtr' : undeclared identifier 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(244): error C2228: left of '.setNom' must have class/struct/union 1> type is ''unknown-type'' 1> 1>Build FAILED. 1> 1>Time Elapsed 00:00:02.35 ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========```
Resistor * resPtr[3]

should be declared globally..

the first error:
 1>f:\ ... \resistormain.cpp(66): error C2660: 'EnterResistance' : function does not take 1 arguments

declared as:` void EnterResistance(Resistor &, bool);`
defined as:` void EnterResistance(Resistor*)`

fix that then move on to the next error.
Ok so here is a snippet of code that I modified...

 ``1234567891011121314151617181920212223242526272829303132333435`` ``````void DisplayResistance(Resistor*);//Changed from (Resistor &, bool) to (Resistor*) void EnterResistance(Resistor*);//Same here void main(void) { Resistor * resPtr[3]; for(int i = 0; i < 3; i++) { resPtr[i] = new Resistor(); EnterResistance(resPtr[i]); } for(int j=0; j<3; j++) { DisplayResistance(resPtr[j]); } for(int i=0; i<3, i++;) { delete resPtr[i]; } system("pause"); } // Function displays all data member values of a Resistor object void DisplayResistance(Resistor*) { //Local variables to hold Resistor data copies double nom, tol, min, max; nom = resPtr[3]*.getNom();//Modified this from resPtr[3]* but the '.' is wrong. tol = resPtr.getTol(); min = nom * (1.0 - tol); max = nom * (1.0 + tol); cout << endl << "Resistor object name is " << resPtr.getName()...``````

Here is the output...

 ```1>------ Build started: Project: wk 5, Configuration: Debug Win32 ------ 1>Build started 2/21/2013 10:01:17 PM. 1>InitializeBuildStatus: 1> Touching "Debug\wk 5.unsuccessfulbuild". 1>ClCompile: 1> ResistorMain.cpp 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(84): error C2059: syntax error : '.' 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(85): error C2228: left of '.getTol' must have class/struct/union 1> type is 'Resistor *[3]' 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(88): error C2228: left of '.getName' must have class/struct/union 1> type is 'Resistor *[3]' 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(116): error C2228: left of '.getNom' must have class/struct/union 1> type is 'Resistor *[3]' 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(117): error C2228: left of '.getTol' must have class/struct/union 1> type is 'Resistor *[3]' 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(118): error C2228: left of '.getName' must have class/struct/union 1> type is 'Resistor *[3]' 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(133): error C2228: left of '.setTol' must have class/struct/union 1> type is 'Resistor *[3]' 1>f:\my documents\visual studio 2010\projects\wk 5\wk 5\resistormain.cpp(244): error C2228: left of '.setNom' must have class/struct/union 1> type is 'Resistor *[3]' 1> 1>Build FAILED. 1> 1>Time Elapsed 00:00:01.69 ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========```

So I know its something to do with the resPtr.ect... lines but not sure how to fix that. Can anyone help?
Last edited on
cout << "Bump" << endl; //;)
The dot operator doesn't work with pointers, so you need to use the -> operator to call the objects functions. Resobj doesn't exist anywhere not even in main, certainly not as a local variable in your function, as the compiler says.

However I think your code needs a bit of reorganising.

In the resitormain.cpp file you have all these functions to do with resistors - they should all be class functions which are called through the resistor object.

Also main always returns an int - not void.

Lines 141 to 244 would be much better written with switch statements.

Each case clause (Your else if) could call a function. Your else if blocks are all very similar, call a function that has the array & the length of it as parameters. This will avoid quite a bit of repetition in your code.

Lines 10 to 52 should be private member variables in the resistor class. Your member functions can get at them because they are in the same class.

When deleting dynamically created arrays - use the `delete[] `operator

HTH & good luck. :-D

Thank you guys for the help thus far... After all your help here is my complete Resistormain...

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245`` ``````#include "Resistor.h" #include #include #include #include using namespace std; Resistor * resPtr[3]; //EIA Standard array element sizes per tolerance class const int E12 = 12; const int E24 = 24; const int E48 = 48; const int E96 = 96; //EIA Standard Resistor Values //E12 10% tolerance //E24 5% tolerance //E48 2% tolerance //E96 1% tolerance //10% standard values const int nominalE12Values[E12] = { 100, 120, 150, 180, 220, 270, 330, 390, 470, 560, 680, 820}; //5% standard values const int nominalE24Values[E24] = { 100, 110, 120, 130, 150, 160, 180, 200, 220, 240, 270, 300, 330, 360, 390, 430, 470, 510, 560, 620, 680, 750, 820, 910}; //2% standard values const int nominalE48Values[E48] = { 100, 105, 110, 115, 121, 127, 133, 140, 147, 154, 162, 169, 178, 187, 196, 205, 215, 226, 237, 249, 261, 274, 287, 301, 316, 332, 348, 365, 383, 402, 422, 442, 464, 487, 511, 536, 562, 590, 619, 649, 681, 715, 750, 787, 825, 866, 909, 953}; //1% standard values const int nominalE96Values[E96] = { 100, 102, 105, 107, 110, 113, 115, 118, 121, 124, 127, 130, 133, 137, 140, 143, 147, 150, 154, 158, 162, 165, 169, 174, 178, 182, 187, 191, 196, 200, 205, 210, 215, 221, 226, 232, 237, 243, 249, 255, 261, 267, 274, 280, 287, 294, 301, 309, 316, 324, 332, 340, 348, 357, 365, 374, 383, 392, 402, 412, 422, 432, 442, 453, 464, 475, 487, 499, 511, 523, 536, 549, 562, 576, 590, 604, 619, 634, 649, 665, 681, 698, 715, 732, 750, 768, 787, 806, 825, 845, 866, 887, 909, 931, 953, 976}; void DisplayResistance(Resistor*); void EnterResistance(Resistor*); void main(void) { Resistor * resPtr[3]; for(int i = 0; i < 3; i++) { resPtr[i] = new Resistor(); EnterResistance(resPtr[i]); } for(int j=0; j<3; j++) { DisplayResistance(resPtr[j]); } for(int i=0; i<3, i++;) { delete resPtr[i]; } system("pause"); } // Function displays all data member values of a Resistor object void DisplayResistance(Resistor*resPtr) { //Local variables to hold Resistor data copies double nom, tol, min, max; nom = resPtr->getNom();//Modified this from resPtr[3]* but the '.' is wrong. tol = resPtr->getTol(); min = nom * (1.0 - tol); max = nom * (1.0 + tol); cout << endl << "Resistor object name is " << resPtr->getName() << endl; cout << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(3); cout << endl << "Nominal resistance value = " << setw(15) << nom << " ohms "; cout << endl << "Tolerance = " << setw(15) << tol * 100 << " %"; cout << endl << "Minimum Resistance = " << setw(15) << min << " ohms"; cout << endl << "Maximum Resistance = " << setw(15) << max << " ohms"; cout << endl << endl; } // Function allows user to enter new values for Resistor data members void EnterResistance(Resistor*resPtr) { //Local variables to hold Resistor data copies double nom, tol; string name; //Local variable for user data entry int nomEdit = 0; int tolEdit = 0; int powerOfTen = 0; //Valid EIA entry value check boolean bool validEIA = false; //Local loop counter int i = 0; nom = resPtr->getNom(); tol = resPtr->getTol(); name = resPtr->getName(); cout << endl << endl; cout << "Resistor being edited: " << name << endl << endl; do { cout << "Current resistance tolerance = " << tol * 100 << " %" << endl; cout << "Valid tolerances are 1%, 2%, 5% or 10%" << endl << endl; cout << "Enter 1, 2, 5 or 10: "; cin >> tolEdit; cout << endl; } while(tolEdit != 1 && tolEdit != 2 && tolEdit != 5 && tolEdit != 10); cout << "Tolerance set to " << tolEdit << " %" << endl << endl; resPtr->setTol((double)tolEdit*0.01); do { cout << "Current nomimal resistance = " << nom << " ohms" << endl; cout << "Standard 10% Resistance Values, First Three Digits" << endl << endl; if(tolEdit == 10) { for( i = 0; i < E12; i++) { if(!(i % 10)) cout << endl; cout << nominalE12Values[i] << " "; } } else if(tolEdit == 5) { for( i = 0; i < E24; i++) { if(!(i % 10)) cout << endl; cout << nominalE24Values[i] << " "; } } else if(tolEdit == 2) { for( i = 0; i < E48; i++) { if(!(i % 10)) cout << endl; cout << nominalE48Values[i] << " "; } } else { for( i = 0; i < E96; i++) { if(!(i % 10)) cout << endl; cout << nominalE96Values[i] << " "; } } cout << endl << endl << "Enter first three digits: "; cin >> nomEdit; cout << "You entered " << nomEdit << endl; validEIA = false; if(tolEdit == 10) { for( i = 0; i < E12; i++) { if(nomEdit == nominalE12Values[i]) { validEIA = true; cout << "Valid EIA value entered" << endl; } } } else if(tolEdit == 5) { for( i = 0; i < E24; i++) { if(nomEdit == nominalE24Values[i]) { validEIA = true; cout << "Valid EIA value entered" << endl; } } } else if(tolEdit == 2) { for( i = 0; i < E48; i++) { if(nomEdit == nominalE48Values[i]) { validEIA = true; cout << "Valid EIA value entered" << endl; } } } else { for( i = 0; i < E96; i++) { if(nomEdit == nominalE96Values[i]) { validEIA = true; cout << "Valid EIA value entered" << endl; } } } if (validEIA == false) { cout << "Invalid EIA value entered, try again" << endl; } } while(validEIA == false); do { cout << endl << "Enter a power of ten multiplier between -2 (0.01) and 3 (1000): "; cin >> powerOfTen; cout << "You entered " << powerOfTen << endl; } while(powerOfTen < -2 || powerOfTen > 3); resPtr->setNom((double)nomEdit * pow(10.0,(double)powerOfTen)); }``````

I'll probably go in there and clean up some of the code in there later but for now its compiling. Now I just need to figure out how to assign my own resistor.
Topic archived. No new replies allowed.