I'll post the question below but I can't get the smallest and largest to print. I'm not even sure I have the math correct to calculate them because I can't get results to print.
A local zoo wants to keep track of how many pounds of food each of its three monkeys
eats each day during a typical week. Write a program that stores this information
in a two-dimensional 3 × 7 array, where each row represents a different monkey and
each column represents a different day of the week. The program should first have the
user input the data for each monkey. Then it should create a report that includes the
following information:
• Average amount of food eaten per day by the whole family of monkeys.
• The least amount of food eaten during the week by any one monkey.
• The greatest amount of food eaten during the week by any one monkey.
Input Validation: Do not accept negative numbers for pounds of food eaten.
Any help would be great!
#include<iostream>
#include <iomanip>
using namespace std;
// Constants
const int MONKEYS = 3;
const int DAYS = 7;
//function prototypes
double familyAverage(const double mf[MONKEYS][DAYS]);
double littleMeal(const double mf[MONKEYS][DAYS]);
double bigMeal(const double mf[MONKEYS][DAYS]);
int main()
{
double monkey_table [MONKEYS][DAYS]={0};
int x, y;
cout << "Three monkeys are in a zoo and this program will tell us ";
cout << "how much food they eat on average. We will also ";
cout << "tell you the largest and smallest meal they consumed.\n\n";
for (x = 0; x < MONKEYS; x++)
{
for (y = 0; y < DAYS; y++)
{
do
{
cout << "Monkey " << x+1<<" ";
cout << "Day " << y+1 <<" ";
cin >> monkey_table [x][y];
if(monkey_table [x][y] < 0)
cout<<" Please enter a positive number for pounds of food."<<endl;
}
while(monkey_table [x][y] < 0);
}
}
cout << showpoint << fixed << setprecision(2) << endl;
cout << "Average amount of food eaten per day by the whole family of monkeys is "<<familyAverage(monkey_table)<<endl;
system ("pause");
return 0;
}
double familyAverage(const double mf[MONKEYS][DAYS])
{
double total;
for (int x = 0; x < MONKEYS; x++)
for (int y = 0; y < DAYS; y++)
total += mf[x][y];
total= (total / DAYS)/3;
return total;
}
double littleMeal(const double mf[MONKEYS][DAYS])
{
double small= INT_MAX;
for (int x = 0; x < MONKEYS; x++)
for (int y = 0; y < DAYS; y++)
if (mf[x][y] > small)
small= mf[x][y];
cout << "The smallest meal is " << small << endl;
return small;
}
double bigMeal(const double mf[MONKEYS][DAYS])
{
double big= INT_MAX;
for (int x = 0; x < MONKEYS; x++)
for (int y = 0; y < DAYS; y++)
if (mf[x][y] < big)
big= mf[x][y];
cout << "The biggest meal is " << big << endl;
return big;
}