Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you help me this problem with C++ ? I am straggling with is question 1. Write the definition of function main that does the

Can you help me this problem with C++ ? I am straggling with is question

1. Write the definition of function main that does the following:

a. Define an object of the class Demo1 (defined in example C1above)

b. Read two values and set the two member variables of this object to those values.

c. Output the values of the member variables of this object with appropriate messages.

d. Compute and print the average value of the member variables of this object with an appropriate message.

Question 2 Use the definition of the class Demo2 to do the following: 1. Declare object item of the class Demo2.

2. Read the values for the member variables of object item, and set the values of its member variables.

3. Compute the average of the values of the member variables of object item and print it.

4. Write a function named addDemo2( ) that receives as arguments two objects of the class Demo2 and then builds and returns another object of the class Demo2 such that the value of each of its member variables is the sum of the values of the corresponding member variables of its arguments.

5. Write the sequence of statements to do the following:

i. Declare object obj1 and set its member variables to 5 and 7 respectively

ii. Declare object obj2 and set its member variables to 14 and 9 respectively.

iii. Create a third object named objR such that the value of each of its member variables is the sum of the values of the corresponding member variables of objects obj1 and obj2 by calling function addDemo2( ).

6. Write a function incrDemo2 that receives as argument an object of the class Demo2 and increments the value of each of its member variables by 5.

7. Write the statement(s) to increment the value of each member variable of object obj1 by 5 by calling function incrDemo2( ).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

4. Identify the challenges facing todays organizations

Answered: 1 week ago