#include "stdafx.h"
#include <iostream>
#include <iomanip>
using namespace std;
//------------------------prototypes----------------------------------
void ReadData(int &x, int &y, int &z);
float FindMaxMin(int x, int y, int z, float &max, float &min);
float ComputeAve(float x, float y, float z);
void ShowAll(float x, float y, float z, float average, float max, float min);
//--------------------------------------------------------------------
int main()
{
//read data into x, y, and z
int x, y, z;
ReadData(x, y, z);
//compute the average of x, y, z
float average = ComputeAve(x, y, z);
//find the maximum and the minimum of x, y, and z
float max, min;
FindMaxMin(x, y, z, max, min);
//show all results
ShowAll(x, y, z, average, max, min);
//terminate the program
return 0;
}
//---------------------------
// Name: ReadData
// Input: x, y, and z
// Output: None
//---------------------------
void ReadData(int &x, int &y, int &z)
{
cout << "Enter three integer numbers: ";
cin >> x >> y >> z;
}
//-------------------------------------
// Name: FindMaxMin
// Input: None
// Output: Max and min of x, y, and z
//-------------------------------------
float FindMaxMin(int x, int y, int z, float &max, float &min)
{
//FindMax
if (x > y && x > z)
{return x;}
if (y > x && y > z)
{return y;}
else
{return z;}
//FindMin
if (x < y && x < z)
{return x;}
if (y < x && y < z)
{return y;}
else
{return z;}
}
//-----------------------------------------
// Name: ComputeAve
// Input: None
// Output: Compute average of x, y, and z
//-----------------------------------------
float ComputeAve(float x, float y, float z)
{
return (x+y+z)/3;
}
//--------------------------
// Name: ShowAll
// Input: None
// Output: Everything
//--------------------------
void ShowAll(float x, float y, float z, float average, float min, float max)
{
cout << setfill('.');
cout << "For three numbers: " << x << " " << y << " " << z << endl;
cout << fixed << showpoint << setprecision(2);
cout << "\tAverage" << right << setw(30) << "" << average << endl;
cout << "\tMinimum" << right << setw(30) << "" << min << endl;
cout << "\tMaximum" << right << setw(30) << "" << max << endl;
}
can someone tell me why it won't read maximum and minimum?