Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write the Stats class that has three private member variables (num1, num2, and num3; all are integers) and the following member functions: a. Constructor: The

Write the Stats class that has three private member variables (num1, num2, and num3; all are integers) and the following member functions:

a. Constructor: The constructor should accept three integer values as arguments and assign them to the objects member variables. The default constructor should initialize all member variables to 0.

b. getSum: This function calculates and returns the sum of the member variables.

c. getAvg: This function calculates and returns the average value of the member variables. d. getMin: This function returns the smallest member variable.

e. getMax: This function returns the largest member variables.

f. getMedian: This function finds and returns the median of the three member variables.

Write a program that uses the Stats class to display the sum, the average, the min, the max, and the median values of the objects member variables. The program should ask the user to enter the three integer values using the keyboard. Figure 2 is an example snapshot of the programs input and output.

Figure 2

Enter the 1st integer: 20

Enter the 2nd integer: 10

Enter the 3rd integer: 15

The sum is 35

The average is 11.67

The min is 10

The max is 20

The median is 15

Note: To find the median of any set of numbers, put them in order from smallest to greatest. If a number occurs more than once, list it more than once. The number in the middle is the median. If there is an even number of numbers, the median is the average of the two numbers in the middle.

The program should be in c++

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

Expert Performance Indexing In SQL Server

Authors: Jason Strate, Grant Fritchey

2nd Edition

1484211189, 9781484211182

More Books

Students also viewed these Databases questions