Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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 value
m_dptrRes[1] = the tolerance value
m_dptrRes[2] = the max resistance value
m_dptrRes[3] = the min resistance value

The 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 * Tolerance
Max 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 input
string Name;
getline(cin, Name);

//get the number of characters in the string
int length = (int)Name.length(); 

//add one to account for the null character 
m_sptrResName = new char[length + 1]; 

//copy from Name to the pointer
strcpy_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"

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9639602

Have any Question?


Related Questions in Computer Engineering

Decision support systemsnbspvary greatly in application and

Decision support systems  vary greatly in application and complexity, but they all share specific features. A typical Decision support systems has four components: data management, model management, knowledge management ...

Question take screenshots of functions running in clisp

Question : Take screenshots of functions running in cLISP. Provide a description for each screenshot. 1. Create the function DecTree that will implement decision tree. Your function should accept input of decimal string ...

A sample of 1000 us households is taken and the average

A sample of 1,000 U.S. households is taken and the average amount of newspaper garbage or recycling is found to be 27.8 pounds. Assuming the standard deviation of newspaper for garbage or recycling is 2 pounds. Estimate, ...

Subject digital securityprovide an fidm authentication

subject : Digital Security Provide an FIdM authentication system that you have used (being subjet to). Tell the name of the organizations acted as the IdP (Identity Provider) and SP (Service Provider)?

Savings account balance write a program that calculates the

Savings Account Balance Write a program that calculates the balance of a savings account at the end of a period of time. It should ask the user for the annual interest rate, the starting balance, and the number of months ...

A new machine averages 4 clock cycles per instruction and

A new machine averages 4 clock cycles per instruction, and runs at a system clock of 20 MHz. The Axiom-Verge algorithm set to benchmark the system will take an even 3000 instructions to complete. a) Knowing how many cloc ...

A national report indicates that the mean and standard

A national report indicates that the mean and standard deviation of the ACT scores of incoming freshman at American public universities are 24.6 and 6.2, respectively. A sample of 30 incoming freshmen at a small, suburba ...

What to do sort an array of single digit positive integers

What to do: Sort an array of single digit positive integers in LC-3 assembler - program will prompt user to enter a single digit integer. Non-negative values are accepted, with a zero entered to terminate input - the pro ...

Question reversing the elements of an array involves

Question : Reversing the elements of an array involves swapping the corresponding elements of the array: the first with the last, the second with the next to the last, and so on, all the way to the middle of the array. G ...

Does bmw have a guided missile corporate culture and

Does BMW have a guided missile corporate culture, and incubator corporate culture, a family corporate culture, or an Eiffel tower corporate culture?

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As