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

The purpose of this program is to determine the amount of food eaten by a certai

ID: 3802750 • Letter: T

Question

The purpose of this program is to determine the amount of food eaten by a certain kind of animal. You need to use functions for these calculation that incorporate pass-by-value parameters. In addition, you need to include various int or double const declarations within your program. Finally, embed your program in a loop so that the calculation can be repeated as often as the user wishes.

YOU MUST DEFINE AND CALL FUNCTIONS AND PASS ARGUMENTS.

You should base your calculations on the following table:

The following program dialogue should help you figure out what kind of program I am looking for.

Mammals Amphibians Reptiles 1 lb for each 10 lbs in weight 2/3 lb for each 5 lbs in weight 1/5 lb for each 6 lbs in weight 1/3 lb for each foot in height 1/4 lb for each 6 inches in length 1/2 lb for each foot in length 1/10 lb for each 5 years of age 1/5 lb for each 4 years in age Deduct 10% of food during winter Add an extra 15% of food if the animal can run faster than a human Add an extra 10% of food if the animal is pregnant

Explanation / Answer

#include <iostream>

using namespace std;

void Mammals(double w,double h, int age)
{
int run=0;
double food=0;

cout<<"can it run faster than a human? [1=Yes/2=No]:";
cin>>run;

//1 lb for each 10 lbs in weight
food=w/10;
// 1/3 lb for each foot in height
food=food+h/3;

//1/10 lb for each 5 years of age

food=food+((double)age/(5*10));

if(run==1)
{
//Add an extra 15% of food if the animal can run faster than a human
food=food+((food*15)/100);

}

cout<<"For this animal, you'll need " <<food << "lbs of food a week!";

}

void Amphibians(double weight,double inches,int age)
{
int peg=0;
double food=0;

cout<<"Is it pregnant? [1=Yes/2=No]: ";
cin>>peg;


//2/3 lb for each 5 lbs in weight
food=(weight*2)/(5*3);

// 1/4 lb for each 6 inches in length
food=food+ (inches/24);

//1/5 lb for each 4 years in age

food=food+((double)age/(4*5));

if(peg==1)
{
//Add an extra 15% of food if the animal can run faster than a human
food=food+((food*10)/100);

}

cout<<"For this animal, you'll need " <<food << "lbs of food a week!";


}

void Reptiles(double weight, double lenght2)
{

int winter=0;
double food=0;

cout<<"Is it winter? [1=Yes/2=No]: ";
cin>>winter;

   //1/5 lb for each 6 lbs in weight
food=(weight)/(30);

// 1/2 lb for each foot in length
food=food+ (lenght2/2);

if(winter==1)
{
//Add an extra 15% of food if the animal can run faster than a human
food=food-((food*10)/100);

}

cout<<"For this animal, you'll need " <<food << "lbs of food a week!";

}
int main()
{
int choice;
int tr=0;

do{

cout <<"Zoo Food Calculator:"<<endl;
cout<<"Whaddya want? [0]Mammal or [1]Amphibian or [2]Reptile : ";
cin>>choice;


double weight;
double height;
int age;
double inches;

double lenght2;

switch(choice)
{

case 0: cout<<"Gimme its weight in lbs: ";
cin>>weight;
cout<<"Gimme its height in feet:";
cin>>height;
cout<<"Gimme its age:";
cin>>age;

Mammals(weight,height,age); break;

case 1:
cout<<"Gimme its weight in lbs: ";
cin>>weight;
cout<<"Gimme its length in inches:";
cin>>inches;
cout<<"Gimme its age:";
cin>>age;

Amphibians(weight,inches,age); break;

case 2: cout<<"Gimme its weight in lbs: ";
cin>>weight;
cout<<"Gimme its length in feet: ";
cin>>lenght2;

Reptiles(weight,lenght2); break;

default:cout<<"You Entered Wrong Choice !!"<<endl;

}
cout<<endl<<"Try again? [1=Yes/2=No]:";
cin>>tr;
}while(tr==1);
return 0;
}

------------------------------------------------

Output sample :

Zoo Food Calculator:
Whaddya want? [0]Mammal or [1]Amphibian or [2]Reptile : 0
Gimme its weight in lbs: 30.0
Gimme its height in feet:3.2
Gimme its age:10
can it run faster than a human? [1=Yes/2=No]:2
For this animal, you'll need 4.26667lbs of food a week!
Try again? [1=Yes/2=No]:1
Zoo Food Calculator:
Whaddya want? [0]Mammal or [1]Amphibian or [2]Reptile : 1
Gimme its weight in lbs: 30.0
Gimme its length in inches:6
Gimme its age:10
Is it pregnant? [1=Yes/2=No]: 1
For this animal, you'll need 5.225lbs of food a week!
Try again? [1=Yes/2=No]:1
Zoo Food Calculator:
Whaddya want? [0]Mammal or [1]Amphibian or [2]Reptile : 2
Gimme its weight in lbs: 30.0
Gimme its length in feet: 1
Is it winter? [1=Yes/2=No]: 2
For this animal, you'll need 1.5lbs of food a week!
Try again? [1=Yes/2=No]:2

---------------------------------------------------------------------------------------------

If you have any query, please feel free to ask.

Thanks a lot.

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