Question: C++!!!!!!! Class - Friend Functions Class members can access other functions outside of their own member functions called friend functions. 1.Create a class with the

C++!!!!!!!

Class - Friend Functions

Class members can access other functions outside of their own member functions called friend functions.

1.Create a class with the following member variables and functions:

a)Initialize the member variables n1 and n2;

b)Add two numbers and return the sum (n1 + n2)

c)Subtract two numbers and return the difference (n1 n2)

d)Multiply two numbers and return the product (n1 * n2)

e)Divide two numbers and return the dividend (n1 / n2). If n2 is zero, set n2 to 1.

2.The class has several friend functions:

a)Average pass the class object and return the average of n1 and n2

b)Compare1 pass the class object and return the Larger of n1 and n2. If n1 and n2 are equal zero to signal that n1 and n2 are equal

c)Compare2 pass the class object and return the Smaller of n1 and n2. If n1 and n2 are equal zero to signal that n1 and n2 are equal

3.Allow the user to run this as many times as they wish during the applications execution

Output Example:

1 of 2 - Enter First numeric Value: 22.3

2 of 2 - Enter Second numeric Value: 44.5

First Value is 22.3

Second Value is 44.5

22.3 + 44.5 = 66.8

22.3 - 44.5 = -22.2

22.3 X 44.5 = 992.35

22.3 / 44.5 = 0.501124

Average of 66.8 is 33.4

The Larger of 22.3 and 44.5 is 44.5

The Smaller of 22.3 and 44.5 is 22.3

Run this Again (Y or N):

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!