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

Monkey Business A local zoo wants to keep track of how many pounds of food each

ID: 3555059 • Letter: M

Question

Monkey Business 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 monkeys are represented by integers 1, 2, and 3: the weekdays are " Sunday", "Monday", "Tuesday", "Wednesday", "Thursday". "Friday". "Saturday". The program should first prompt the user to input the data for each monkey, starting with "Sunday" for monkey #1, then monkeys #2 and #3, followed by "Monday" for monkey #1. then monkeys #2 and #3 and so on, through "Saturday". The program then creates a report that includes the following information, each properly labeled (see below): 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. When a negative value Is entered, the program outputs "invalid (negative) food quantity - reenter" and attempts to reread the value . Prompts And Output Labels: Decimal values should be displayed using default precision, i.e. do not specify precision. Each item read should be prompted for by a string of the form "Enter the food eaten by monkey #N on DAY: " when N Is 1 or 2 or 3 and DAY is "Sunday" or "Monday" or ... or "Saturday". The output should be of the form: Average food consumed daily: 6.23. The least daily food consumed was by monkey #0 on Friday. The most daily food consumed was by monkey #2 on Sunday. where the specific amount of food or specific monkeys or specific days identified depend on the actual input.

Explanation / Answer

#include<iostream>
using namespace std;
int main()
{
double data[3][7];
for(int i=0;i<7;i++)
{
for(int j=0;j<3;j++)
{
cout<<endl<<"enter data for monkey # "<<j+1<<" for day # "<<i+1;
cin>>data[j][i];
if (data[j][i]<0)
{
while(data[j][i]<0)
{
cout<<endl<<"please re enter : ";
cin>>data[j][i];
}
}
}
}

double sum=0;
for(int i=0;i<3;i++)
{
for(int j=0;j<7;j++)
{
sum=sum+data[i][j];
}
}
double avg=sum/7;
cout<<endl<<"average food eaten is "<<avg<<" pounds.";
int monkey1=0;
int monkey2=0;
double least=10000;//some arbitrary high value
int day1=0;
int day2=0;
double greatest=0;
for(int i=0;i<3;i++)
{
for(int j=0;j<7;j++)
{
if(data[i][j]<least)
{


least=data[i][j];
monkey1=i+1;
day1=j+1;
}
if(data[i][j]>greatest)
{
greatest=data[i][j];
monkey2=i+1;
day2=j+1;
}
}

}

cout<<endl<<"the least amount eaten is "<<least<<" by moneky # "<<monkey1<<" on day # "<<day1;
cout<<endl<<"the greatest amount eaten is "<<greatest<<" by moneky # "<<monkey2<<" on day # "<<day2;
}

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