must work in C++ with visual studios 2008

QUESTION

must work in C++ with visual studios 2008:Objective: Create a C++ console application that utilizes the core concepts of inheritance and pointers by creating a class and a program that tests important features of that class.Overview: This lab will require you to use C++ class inheritance to define and use a resistor class derived from a base resistor class. The program will allow the user to specify resistor component types and values.You will be required to define a base class (ResistorClass) for a generic resistor device and a derived classes (FancyResistorClass) for specific resistor device type.Resistor Class UML Diagram (# indicates a protected member):Class: ResistorClass# double *m_dptrRes# char *m_sptrResName+ int m_istResCounter (static)+ void DisplayResistor(void)+ void EnterResistance (void)+ ResistorClass( )+ ResistorClass(char Name[], double nominalResistance, double Tolerance)+ ~ResistorClass( )Begin work on this program by first coding the Resistor Class class declaration. Then code and test the Resistor class constructor functions one at a time. Code and test the rest of the functions one function at a time. To avoid compiler complaints, comment out the member function prototypes in the Resistor Class declaration that have not yet been completed.specifications:This is the default constructor.* You will need to create two dynamic arrays using the new operator. The first array will store the resistor values (nominal, tolerance, min and max) and the second array (a character array) will hold the resistor’s name.* The resistor array will have four elements. The values stored in the array will be of data type double. The values will be stored to the array in the following positions:m_dptrRes[0] = the nominal resistance valuem_dptrRes[1] = the tolerance valuem_dptrRes[2] = the max resistance valuem_dptrRes[3] = the min resistance valueThe nominal value should be initialized to 1000.0 and the tolerance value should be initialized to .10.The minimum and maximum resistance should then be calculated using the nominal and tolerance variables. The formulas are:Minimum Resistance = Nominal – Nominal * ToleranceMax Resistance = Nominal + Nominal * Tolerance* The user should be prompted to supply a name for the resistor. The value supplied by the user will be stored using the resistor’s name pointer. To conserve memory the name array should allocate only enough room to hold the number of characters supplied by the user. You’ll want the user’s entry to be saved to a string variable using the getline function. Then you’ll need to determine the number of characters in the string variable, allocate the required memory and copy the characters from the string variable to the pointer. This requirement is more for demonstration purposes than it is for practicality. Here is the essential code://get the user’s inputstring Name;getline(cin, Name);//get the number of characters in the stringint length = (int)Name.length();//add one to account for the null characterm_sptrResName = new char[length + 1];//copy from Name to the pointerstrcpy_s(m_sptrResName, length + 1, Name.c_str());The strcpy_s function performs a deep-copy of character array data. You could replace the strcpy_s function with a for/loop that performs a deep copy. The syntax for strcpy_s is as follows:strcpy_s(char *Destination,int numberOfElements,char *Source);* To keep count of the number of resistor objects in existence, be sure to increment the static variable m_istResCounter.* Be sure to include an output statement that displays the message “Default Constructor Called”

 

ANSWER:

REQUEST HELP FROM A TUTOR

Expert paper writers are just a few clicks away

Place an order in 3 easy steps. Takes less than 5 mins.

Calculate the price of your order

You will get a personal manager and a discount.
We'll send you the first draft for approval by at
Total price:
$0.00