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

C++ only! A local zoo wants to keep track of how many pounds of food each of its

ID: 3596940 • Letter: C

Question

C++ only!

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 x 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 money.

output must be like:

part of my solution: (I'm not sure if its correct)

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main() {

float food[3][7];
float temp, totalFood = 0, avg;
float least, most;

for (int i = 0; i<1; i++) {
for (int j = 0; j<7; j++) {
cout << "Enter the pounds eaten by monkey number " << i + 1 << " on day " << j + 1 << " :" << endl;
cin >> temp;

while (temp < 0) {
cout << "Negative numbers not allowed" << endl;
cin >> temp;
}
food[i][j] = temp;
}
}
cout << endl;

for (int i = 1; i<2; i++) {
for (int j = 0; j<7; j++) {
cout << "Enter the pounds eaten by monkey number " << i + 1 << " on day " << j + 1 << " :" << endl;
cin >> temp;

while (temp < 0) {
cout << "Negative numbers not allowed" << endl;
cin >> temp;
}
food[i][j] = temp;
}
}
cout << endl;

for (int i = 2; i<3; i++) {
for (int j = 0; j<7; j++) {
cout << "Enter the pounds eaten by monkey number " << i + 1 << " on day " << j + 1 << " :" << endl;
cin >> temp;

while (temp < 0) {
cout << "Negative numbers not allowed" << endl;
cin >> temp;
}
food[i][j] = temp;
}
}
cout << endl;

5649 816411686719117361942

Explanation / Answer

Please find below code.

#include<iostream>

using namespace std;

float A[3][7];
string getDay(int j)
{
if(j==0)
{
return "Sunday";
}
else if (j==1)
{
return "Monday";
}
else if (j==2)
{
return "Tuesday";
}
else if (j==3)
{
return "Wednesday";
}
else if (j==4)
{
return "Thursday";
}
else if (j==5)
{
return "Friday";
}
else if (j==6)
{
return "Saturday";
}
return "Error";
}

void printInput(int i,int j)
{
cout<<"Enter the food eaten by monkey #"<<(i+1)<<" on "<<getDay(j)<<": ";
}

void average()
{
float totalaverage=0;
for(int j=0;j<7;j++)
{
for(int i=0;i<3;i++)
{
totalaverage=totalaverage+A[i][j];
}   
}
totalaverage=totalaverage/7;
cout<<"Average food consumed daily: "<<totalaverage<<"."<<endl;
}

void leastConsumption()
{
float min=A[0][0];
int m=0;
int day=0;
for(int i=0;i<3;i++)
{
for(int j=0;j<7;j++)
{
if(min>A[i][j])
{
min=A[i][j];
m=i;
day=j;
}
}   
}
cout<<"The least daily food consumed was by monkey #"<<(m+1)<<" on "<<getDay(day)<<"."<<endl;
}

void maxConsumption()
{
float max=A[0][0];
int m=0;
int day=0;
for(int i=0;i<3;i++)
{
for(int j=0;j<7;j++)
{
if(max<A[i][j])
{
max=A[i][j];
m=i;
day=j;
}
}   
}
cout<<"The most daily food consumed was by monkey #"<<(m+1)<<" on "<<getDay(day)<<"."<<endl;
}

int main()
{
// float A[3][7];
for(int i=0;i<3;i++)
{
for(int j=0;j<7;j++)
{
float value=-1;
while(value<0)
{
printInput(i,j);
cin>>value;
  
if(value<0)
{
cout<<"invalid (negative) food quantity-reenter"<<endl;
}
}
A[i][j]=value;
}
}
average();
leastConsumption();
maxConsumption();
  
}

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