Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I just ran the following code: #include <iostream> #include <string> #include <i

ID: 3584383 • Letter: I

Question

I just ran the following code:

#include <iostream>

#include <string>

#include <iomanip>


using namespace std;


//

//CLASS DECLARATION SECTION

//

class ResistorClass {

public:

// public data member

string m_cResistorName;

// public member functions

void DisplayResistor(void);

void EnterResistance(void);

void AddSeries (const ResistorClass& , const ResistorClass&);

// public constructors/destructor

ResistorClass();

ResistorClass(string Name, double nominalResistance, double Tolerance);

ResistorClass(const ResistorClass &ResistorObject);

~ResistorClass();


private:

// private data members

double m_dResValue;

double m_dTolerance;

double m_dMinResistance;

double m_dMaxResistance;

};


int main()

{

/*********************************

* Create a Resistor Class object called oResOne. This object should be

instantiated using the default constructor.

* Create a Resistor Class object called oResTwo. This object should be

instantiated using the parameterized constructor with the following arguments:

Name = "Resistor 2"

Nominal resistance = 4700 ohms

Resistor tolerance = 20%

* Using the copy constructor, create a third Resistor Class object called

oResThree. Pass oResTwo as an argument to the copy constructor.

* The program should then display the current values of all three Resistor

objects using the member function DisplayResistor( ).

**********************************/

{

//Create the first resistor

ResistorClass oResOne;


//Create the second resistor

ResistorClass oResTwo("Resistor 2", 4700, 0.20);


//Create the third resistor

ResistorClass oResThree = oResTwo;


//Add Resistor 2 to Resistor 3

oResThree.AddSeries(oResOne,oResTwo);


//Display the values of the resistor objects

oResOne.DisplayResistor();

oResTwo.DisplayResistor();

oResThree.DisplayResistor();

}

cin.ignore(2);


} //end main


//

//CLASS IMPLEMENTATION SECTION


//prompt for m_cResistorName

//Set m_dResValue = 1000.0

//Set m_dTolerance = 0.10

ResistorClass::ResistorClass()

{

string inputStr = "";

cout << "Enter resistor name (default): "; cin >> inputStr;

m_cResistorName = inputStr;

m_dResValue = 1000.0;

m_dTolerance = 0.10;

//Calculate new Values

m_dMinResistance = m_dResValue - (m_dResValue * m_dTolerance);

m_dMaxResistance = m_dResValue + (m_dResValue * m_dTolerance);

cout << "default constructor called" << endl;

}

ResistorClass::ResistorClass(string Name, double nominalResistance, double Tolerance)

{

m_cResistorName = Name;

m_dResValue = nominalResistance;

m_dTolerance = Tolerance;

//Calculate new Values

m_dMinResistance = m_dResValue - (m_dResValue * m_dTolerance);

m_dMaxResistance = m_dResValue + (m_dResValue * m_dTolerance);

cout << "parameterized constructor called" << endl;

}

ResistorClass::ResistorClass(const ResistorClass &ResistorObject)

{

string inputStr = "";

cout << "Enter resistor name (copy): "; cin >> inputStr;

m_cResistorName = inputStr;

m_dResValue = ResistorObject.m_dResValue;

m_dTolerance = ResistorObject.m_dTolerance;

m_dMaxResistance = ResistorObject.m_dMaxResistance;

m_dMinResistance = ResistorObject.m_dMinResistance;

cout << "copy contructor called" << endl;

}

ResistorClass::~ResistorClass()

{

cout << "Destructor called for " << m_cResistorName << endl;

}


void ResistorClass::DisplayResistor (){

//Displays all Resistor object data members


//set the output parameters

cout << setprecision(2); //see Ch3 page 136 in text book

cout << fixed << showpoint;


//display the output

cout << " ";

cout << setprecision(5) << fixed << showpoint << setfill(' ');

cout << "Values for " << m_cResistorName << " are: " ;

cout << left << setw(25) << "Resistor Nominal Value = "

<< right << setw(10) << m_dResValue << " ";

cout << left << setw(25) << "ohmsResistorTolerance = "

<< right << setw(10) << m_dTolerance * 100 << "% ";

cout << left << setw(25) << "Mininimum Resistance = "

<< right << setw(10) << m_dMinResistance << " ohms ";

cout << left << setw(25) << "Maximum Resistance = "

<< right << setw(10) << m_dMaxResistance << " ohms " ;


}


It showed the image pasted above. I need to know if that is running correctly or not. Please help.....??

Explanation / Answer

please give rathing (lifesever) first to me

yes it is correct