Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Statistical And Scientific Database Management International Working Conference Ssdbm Rome Italy June 21 23 1988 Proceedings Lncs 339

Authors: Maurizio Rafanelli ,John C. Klensin ,Per Svensson

1st Edition

354050575X, 978-3540505754

More Books

Students also viewed these Databases questions