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

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

7) 20 points) write a complete C++ program that accomplishes the task indicated below. Use good form by luding and identifiers. Be accurate with the syntax as if you were typing the program on the computer. Assume that there is a file on disk named xt that contains information about all the animals in the Bronx Zoo. Each line contains a name of an animal (a string with no spaces), a count for that type of animal in the zoo and a character indicating whether the animal is endangered or not ('y" means yes and 'n' means no). Aardvark African WildDog The first line means that the Bronx zoo has 3 Aardvarks it is an endangered species The second line means that there are 2 African Wild Dogs in the Bronx Zoo and they are NOT endangered write the with the assumption that you do not know how many lines are in the program list. You may assume that there are ne spaces in the beach names, write a C++ program that will do the following: Open the file For each line ofdata, you must:

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