Hello, I have a task in C++:
My task is: Create a zoo structure to represent animals at a zoo. Let the structure contain the following data: number (integer), name, weight (in kilograms). Declare an array with three elements of the described zoo structure and test the following functions. Create the following features:
• Function animal_create by which the keyboard is entered: number, name, weight(0.5 t)
• Function output_animal to derive animal data
• Function double_weight that doubles the weight of all animals
What I have tried: view in file or:
[COLOR=#24292F][FONT=-apple-system]
Code:
#include<iostream>
#include<windows.h>
#include<iomanip>
#include<string.h>
using namespace std;
struct zoo{
int number;
char name [30];
double kg;
char push_back [30];
};
void animal_create (zoo[]){
cout<<"Number: ";
cin>>zoo.number;
cout<<"Name: ";
cin>>zoo.name;
cout<<"Weight: ";
cin>>zoo.kg;
}
void output_animal(zoo[]){
cout<<"Number "<<setw(10)<<"Name "<<setw(10)<<"Weight "<<"\n";
cout<<zoo.number<<" "<<zoo.name<<" "<<zoo.kg<<"\n";
}
void double_weight(zoo[]){
int i;
for(int i=0; i<3; i++){
zoo[i].kg=zoo.kg*2;
}
}
int main(){
cout<<"Add animal: ";
cin>>zoo.push_back;
cout<<"Enter data: ";
int j;
for(int j=0; j<3; j++)
animal_create(zoo[i]);
return 0;
}