#include <iostream>
using namespace std;
class Math
{
private:
int num1, num2, num3, num4, num5;
public:
Math(int first, int second, int third, int fourth, int fifth);
int Largest(); // Return the largest number
int Smallest(); // Return the smallest number
double Average(); // Return the average of the numbers
int Total(); // Return the total of the numbers
};
//**************************************************************
// Function: Math
//
// Purpose:
//
// initialize the data in the class to those values provided by whoever calls it.
//
// Parameters:
//
// num1- first number
// num2- second number
// num3- third number
// num4- fourth number
// num5- fifth number
//
// Returns:
//
// passes the numbers
//
//**************************************************************
Math::Math(int first, int second, int third, int fourth, int fifth)
{
num1 = first;
num2 = second;
num3 = third;
num4 = fourth;
num5 = fifth;
}
//**************************************************************
// Function: Largest
//
// Purpose:
//
// Determines the largest number
//
// Parameters:
//
// num1- first number
// num2- second number
// num3- third number
// num4- fourth number
// num5- fifth number
//
// Returns:
//
// the largest number
//
//**************************************************************
int Math::Largest()
{
int answer = num1;
if (num2 > answer) answer = num2;
if (num3 > answer) answer = num3;
if (num4 > answer) answer = num4;
if (num5 > answer) answer = num5;
return answer;
}
//**************************************************************
// Function: Smallest
//
// Purpose:
//
// Determines the smallest number
//
// Parameters:
//
// num1- first number
// num2- second number
// num3- third number
// num4- fourth number
// num5- fifth number
//
// Returns:
//
// the smallest number
//
//**************************************************************
int Math::Smallest()
{
int answer = num1;
if (num2 < answer) answer = num2;
if (num3 < answer) answer = num3;
if (num4 < answer) answer = num4;
if (num5 < answer) answer = num5;
return answer;
}
int Math::Total()
{
return num1 + num2 + num3 + num4 + num5;
}
double Math::Average()
{
return Total() / 5.0;
}
// Test main
int main()
{
Math Object1(10, 20, 30, 25, 15);
Math Object2(5, 10, 6, 2, 8);
cout << "Object1 - Largest: " << Object1.Largest() << endl;
cout << "Object1 - Smallest: " << Object1.Smallest() << endl;
cout << "Object1 - Total: " << Object1.Total() << endl;
cout << "Object1 - Average: " << Object1.Average() << endl;
cout << "Object2 - Largest: " << Object2.Largest() << endl;
cout << "Object2 - Smallest: " << Object2.Smallest() << endl;
cout << "Object2 - Total: " << Object2.Total() << endl;
cout << "Object2 - Average: " << Object2.Average() << endl;
return 0;
}