//Ryan Robateau CSC5 Chapter 7, p. 444, #4
//
/*******************************************************************************
*
* Compute Food Eaten
*______________________________________________________________________________
* This program will enter the amount of pounds of food eaten every day.
* After getting all the data it will display the average daily food eaten.
*____________________________________________________________________________
******************************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
const int MONKEYS = 3;
const int DAYS = 7;
float monkeyFeed[MONKEYS][DAYS]; // INPUT - Pound of food
float totalFood; // OUTPUT - Total amount of food
float highest; // OUTPUT - Highest amount of food
float lowest; // OUTPUT - Lowest amount of food
float averageFood; // OUTPUT - average of amount of food
for(int i = 0; i < MONKEYS; i++)
{
for(int j = 0; j < DAYS; j++)
{
cout << "Monkey " << (i +1);
cout << ", Day " << (j + 1) << ": " << endl;
cin >> monkeyFeed[i][j];
}
}
for(int i = 0; i < MONKEYS; i++)
{
for(int j = 0; j < DAYS; j++)
totalFood += monkeyFeed[i][j];
}
averageFood = totalFood / 21;
highest = monkeyFeed[0][0];
for(int i = 0; i < MONKEYS; i++)
{
for(int j = 0; j < DAYS; j++)
{
if(monkeyFeed[i][j] > highest)
highest = monkeyFeed[i][j];
}
}
lowest = monkeyFeed[0][0];
for(int i = 0; i < MONKEYS; i++)
{
for(int j = 0; j < DAYS; j++ )
{
if(monkeyFeed[i][j] < lowest)
lowest = monkeyFeed[i][j];
}
}
//OUTPUT RESULTS
cout << "Average Amount of Food Eaten per Day: ";
cout << setprecision(2) << fixed <<averageFood << endl;
cout << "Least Amount of Food Eaten: " << lowest << endl;
cout << "Greatest Amount of Food Eaten: " << highest << endl;
return 0;
}