Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A local zoo wants to keep track of how many pounds of food each of its three mon

ID: 3703789 • Letter: A

Question

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 × 5 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:

• The 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

Explanation / Answer

As per above equations

#include <iostream>
#include <string>
using namespace std;
int main()
{
  
float monkeys[3][5];
for(int i=0;i<3;i++)
{
for(int j=0;j<5;j++)
{
float pounds;
cout<<"Enter the no.of.pounds eaten by the monkey "<< (i+1)<< " on day "<<(j+1)<<": ";
cin>>pounds;
if(pounds>=0)
monkeys[i][j]=pounds;
else
{
cout<<"Enter a valid value greater than or equal to 0 ";
j--;
}
  
}
cout<<" ";
}
  
cout<<"Average amount of food eaten per day by the whole family of monkeys: ";
  
for(int j=0;j<5;j++)
{
  
float avg= (monkeys[0][j]+monkeys[1][j]+monkeys[2][j])/3;
cout<<"Average for day "<<(j+1)<<" is: "<<avg<<" ";
  
}
  
float min=monkeys[0][0],max=monkeys[0][0],r1,c1,r2,c2;;
for(int i=0;i<3;i++)
{
for(int j=0;j<5;j++)
{
if(monkeys[i][j]<min)
{
min=monkeys[i][j];
r1=i;c1=j;
}
  
if(monkeys[i][j]>max)
{
max=monkeys[i][j];
r2=i;c2=j;
}
}
  
}
cout<<" Least amount of food "<< min<<" pounds eaten by the monkey "<<(r1+1)<<" on day "<<(c1+1)<<" ";
cout<<" Greatest amount of food "<< max<<" pounds eaten by the monkey "<<(r2+1)<<" on day "<<(c2+1)<<" ";
  
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote