samee question plz do part a and part b thanks 7) 20 points) write a complete C+
ID: 3581147 • Letter: S
Question
samee question plz do part a and part b thanks
Explanation / Answer
#include<bits/stdc++.h>
using namespace std;
string attention(int animal,char y_n)
{
if(animal<10&&y_n=='y')
return "yes";
return "no";
}
int main(int argc, char const *argv[])
{
ifstream f("BronsZooAnimals.txt.txt");
string name;
int animal;
char y_n;
int total_animal=0;
int en_animal=0;
int spe_animal=0;
cout<<"ANIMAL AMOUNT ENDANGERED NEEDS ATTENTION ";
cout<<"--------------------------------------------- ";
while(f>>name>>animal>>y_n)
{
cout<<name<<" "<<animal<<" "<<y_n<<" "<<attention(animal,y_n)<<endl;
total_animal+=animal;
if(y_n=='y')
en_animal+=animal;
if(attention(animal,y_n)=="yes")
{
spe_animal+=animal;
}
}
cout<<"There are "<<total_animal<<" animals in the zoo ";
cout<<"There are "<<en_animal<<" endangered animals in the zoo ";
cout<<"There are "<<spe_animal<<" animals that need special attention ";
return 0;
}
=============================================================================
Output:
akshay@akshay-Inspiron-3537:~/Chegg$ g++ animal.cpp
akshay@akshay-Inspiron-3537:~/Chegg$ ./a.out
ANIMAL AMOUNT ENDANGERED NEEDS ATTENTION
-----------------------------------------------------------------------------------
AradVarak 3 y yes
AfricanWildDog 2 n no
There are 5 animals in the zoo
There are 3 endangered animals in the zoo
There are 3 animals that need special attention
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.