//Nathan Dominguez CSC5 Chapter 7, P. 444, #4
//
/*******************************************************************************
*
* Compute Pounds of Bananas Eaten in a Week by Monkeys
* _____________________________________________________________________________
* This program will store how many pounds of food each of its three monkeys
* eats each day during a typical week. It will then calculate the average
* number of bananas eaten per day. The program will also display the least
* and most amounts eaten in a week.
* _____________________________________________________________________________
* INPUT
* poundsEaten[][] : The number of pounds eaten per monkey per day
*
* OUTPUT
* highest : The highest number of pounds eaten
* lowest : The lowest number of pounds eaten
* total : The total number of pounds eaten
* average : The average number of pounds eaten
*
******************************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int poundsEaten[3][7]; //array size
// per monkey/day
int highest = 0; // OUTPUT - The most # of lbs eaten by any monkey
int lowest = 0; // OUTPUT - The lowest # of lbs eaten by any monkey
int total = 0; // OUTPUT - The total # of lbs eaten by all monkeys
float average; // OUTPUT - The average # of lbs eaten for all monkeys
//loop program for 3 monkeys for 7 days each
for(int monkey = 0; monkey < 3; monkey++){
for(int day = 0; day < 7; day++){
cout << "Monkey " << monkey + 1;
cout << ", Day " << day + 1 << ": ";
cin >> poundsEaten[monkey][day];
cout << endl;
//Accumulate the Total Pounds Eaten
total += poundsEaten[monkey][day];
}
cout << endl;
}
//declare Lowest and Highest
lowest = poundsEaten[0][0];
highest = poundsEaten[0][0];
//nested loop to compare each monkey
for(int monkey = 0; monkey < 3; monkey++)
{
for(int day = 0; day < 5; day++)
{
if(poundsEaten[monkey][day] < lowest)
{
lowest = poundsEaten[monkey][day];
}
if(poundsEaten[monkey][day] > highest)
{
highest = poundsEaten[monkey][day];
}
}
}
//compute Average Pounds Eaten
average = total/15.0;
//output Results
cout << "The daily average is: " << average << endl;
cout << "The least amount eaten: " << lowest << endl;
cout << "The most amount eaten: " << highest << endl;
return 0;
}