Answer to Question #181215 in C++ for Anynomous

Question #181215

A local zoo wants to keep track of how many pounds of food each animal eats each day during a typical week. Write a program that stores this information in a two-dimensional 3 × 4 array, where each row represents a different animal and each column represents a different day of the week. The program should first have the user input the species and then the data for each animal. Then it should create a report that includes the following information:


Input Validation: Do not accept negative numbers for pounds of food eaten.

 


 

  1. Desk Check 
  • Include at least three detailed desk check

 


Create a function:

• Get food eaten

• 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.
  • Allow user to repeat
  • Format output to two decimal places

 


 

Expected Output

Check each Mimir test case for expect output

 


1
Expert's answer
2021-04-14T04:22:30-0400
#include <iostream>

using namespace std;

int main()
{//declaration of 2darray
int arr[4][10];
float avg[10];
//reading input from user

for(int i=0;i<3;i++)
{ cout<<"enter the data for monkey"<<i<<" :";
for(int j=0;j<7;j++)
{
cin>>arr[i][j];
if(arr[i][j]<0)
{
cout<<"enter postive numbers for pounds of food eaten";
  
return 0;
}
}

}
//caluclating average
for(int j=0;j<7;j++)
{
avg[j]=float(arr[0][j]+arr[1][j]+arr[2][j])/3;
}
//calucating largest and smallest amount of food eaten by monkeyes
int largest=arr[0][0];
int smallest=arr[0][0];

for(int i=0;i<3;i++)
{
for(int j=0;j<7;j++)
{
if(largest<arr[i][j])
{
largest=arr[i][j];
//column location of largest element
}

if(smallest>arr[i][j])
{
smallest=arr[i][j];
//column location of smallest element
}
}
}
cout<<"_________________Report__________________"<<endl;
cout<<"Average food eaten by monkeys:"<<endl ;
for(int j=0;j<7;j++)
{
cout<<"Day "<<j+1<<":" <<avg[j]<<endl;
}
cout<<"The least amount of food eaten by monkeys :"<<smallest<<endl;
cout<<"The greatest amount of food eaten by monkeys :"<<largest;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS