//Roman Lara Delgado CSC5 Chapter 7, P.444, #4
//
/*******************************************************************************
*
* Track Monkeys' Food Consumption
*_______________________________________________________________________________
* This program tracks the daily food consumption of three monkeys at a local zoo
* during a typical week. It calculates and generates a report including the
* average amount of foodveaten per day by the whole family of monkeys, the least
* amount of food eaten during the week by any one monkey, and the greatest
* amount of food eaten during the week by any one monkey.
* ______________________________________________________________________________
* INPUT
* pounds[][] : amount of food consumed by each monkey each day of the week
*
* OUTPUT
* averagePounds : Avg. food amount eaten per monkey per day
* highestAmount : highest amount of food consumed by a monkey in a day
* lowestAmount : lowest amount of food consumed by a monkey in a day
*
*******************************************************************************/
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main ()
{
/***************************************************************************
* CONSTANTS
* -------------------------------------------------------------------------
* MONKEYS : number of monkeys
* DAYS : number of days in a week
* ************************************************************************/
//Initialize Program Constants
const int MONKEYS = 3; //CONSTANT - Number of monkeys
const int DAYS = 7; //CONSTANT - Number of days.
float pounds[MONKEYS][DAYS]; /*INPUT - amount of food consumed by each
monkey each day of the week */
//Name of the Days in a Week
string nameDay[DAYS] = {"Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"};
//Delcare Program Variables
string highestDayName; //OUTPUT - day monkey consumed most food
string lowestDayName; //OUTPUT - day monkey consumed least food
float totalPounds; //CALC - tota amount of food consumed by monkeys
float averagePounds; /*OUTPUT - Average food amount consumed
per monkey per day */
float highestAmount; /*OUTPUT - highest food amount consumed
by monkey in a day */
float lowestAmount; /*OUTPUT - lowest food amount consumed
by monkey in a day */
//Input Pounds of Food Consumed Each Day
for (int monkey = 0; monkey < MONKEYS; monkey++)
{
for (int day = 0; day < DAYS; day++)
{
cout << "Enter the amount of pounds of food eaten by monkey #";
cout << monkey + 1 << " on " << nameDay[day] << ": ";
cin >> pounds[monkey][day];
cout << endl;
}
cout << endl;
}
//Output Average Amount of Food Consumed Each Day by Each Monkey
for (int day = 0; day < DAYS; day++)
{
totalPounds = 0;
for (int monkey = 0; monkey < MONKEYS; monkey++)
{
totalPounds += pounds[monkey][day];
}
averagePounds = totalPounds / MONKEYS;
cout << setprecision(2) << fixed;
cout << "Average amount of food eaten on " << nameDay[day]
<< " is " << averagePounds << endl;
}
highestDayName = nameDay[0];
highestAmount = pounds[0][0];
//Determine Highest Amount of Food Consumed by Each Monkey
for (int monkey = 1; monkey < MONKEYS; monkey++)
{
for (int day = 1; day < DAYS; day++)
{
if (pounds[monkey][day] > highestAmount)
{
highestAmount = pounds[monkey][day];
highestDayName = nameDay[day];
}
}
}
lowestDayName = nameDay[0];
lowestAmount = pounds[0][0];
//Determine Lowest Amount of Food Consumed by Each Monkey
for (int monkey = 1; monkey < MONKEYS; monkey++)
{
for (int day = 1; day < DAYS; day++)
{
if (pounds[monkey][day] < lowestAmount)
{
lowestAmount = pounds[monkey][day];
lowestDayName = nameDay[day];
}
}
}
//Output Highest and Lowest Amount of Food Consumed During the Week
cout << endl;
cout << "The highest amount of food eaten during the week was on ";
cout << highestDayName << " with: " << highestAmount << " pounds.";
cout << endl;
cout << "The lowest amount of food eaten during the week was on ";
cout << lowestDayName << " with: " << lowestAmount << " pounds.";
cout << endl;
return 0;
}