Answered You can hire a professional tutor to get the answer.

QUESTION

Use a structure to represent the Animal o Your code will not compile until you create the members listed above 2. Use an enumeration to represent...

Write a C program for the instructions below. Please read the instructions carefully and make sure they are followed correctly.  

please put comment with code! and please do not just copy other solutions.

This assignment is about Structures and Enumerations. Should have (main.c , zoo_food_calculator.c , zoo_food_calculator.h )

you don't need to make exactly same output as sample ouput, but value must same as sample ouput.

given code - zoo_food_calculator.c

#include "zoo_food_calculator.h"

float process_mammal(Animal* animal)

{

//fill

}

float process_amphibian(Animal* animal)

{

//fill

}

float process_reptile(Animal* animal)

{

//fill

}

// helper function to print an animal, use where ever you see fit.

void print_animal(Animal* animal)

{

char buf[4];

switch (animal->type)

{

case mammal:

if (animal->faster_than_human)

strcpy(buf, "yes");

else

strcpy(buf, "no");

printf("mammal, weight: %f, height: %f, age: %d, faster than human: %sn", animal->weight, animal->height, animal->age, buf);

break;

case amphibian:

if (animal->pregnant)

strcpy(buf, "yes");

else

strcpy(buf, "no");

printf("amphibian, weight: %f, length:%f, age: %d, pregnant: %sn", animal->weight, animal->length, animal->age, buf);

break;

case reptile:

printf("reptile, weight: %f, length:%fn", animal->weight, animal->length);

break;

}

}

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

given code -  zoo_food_calculator.h

typedef enum {

// fill in enum

} AnimalTypeEnum;

typedef struct {

// fill in struct

} Animal;

// function declarations (this is just declaring the functions, not implementing them)

float process_mammal(Animal* animal);

float process_amphibian(Animal* animal);

float process_reptile(Animal* animal);

void print_animal(Animal* animal);

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

don't forget main.c and please finish with given code

  • Attachment 1
  • Attachment 2
  • Attachment 3
  • Attachment 4
I will only be looking for if you successfully used structures and enumerations to complete the assignment. Your assignmentmust:1. Use a structure to represent the Animalo Your code will not compile until you create the members listed above2. Use an enumeration to represent the AnimalType ( mammal , amphibian , reptile )o Your code will compile until you create the enum with the three animal types.3. Declare the structure and enumeration in food_zoo_calculator . h4. Implement the following functions:1. float process_mammal (Animal* animal); )- computes the food in Ibs for the animal according to the rules for mammals2. float process_amphibian(Animal* animal); - computes the food in Ibs for the animal according to the rules for amphibians3. float process_reptile(Animal* animal); - computes the food in Ibs for the animal according to the rules for reptiles. Note:these functions do not require using every member of Animal ; they will each use a subset (e.g. (pregnant is onlyused for amphibians).5. Successfully pass the test cases (this is to verify your enumerations work as intended).Please refer to the original Food Zoo Calculator (Assignment 6) for reference.
Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question