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

A large veterinarian services many pets and their owners. As new pets are added

ID: 3684730 • Letter: A

Question

A large veterinarian services many pets and their owners. As new pets are added to the population of pets being serviced, their information is entered into a flat text file. Each month, the vet requests a listing of all pets sorted by their outstanding bill balance. You have to write a program to produce a report of animals and their owners sorted by their outstanding balances from the data in the flat text file, as follows.

A class named VetShop with the following details

– clients: an array of Animal objects

– A simple main method that calls the following input, sort, and report methods.

– An input method to fill the clients array with Animal objects created with the information in the input text file attached. The first line has the number of clients, followed by the data of one animal in each line.

– A method to sort the array of Animals by bill balance.

– A method to produce an output report with one Animal per line.

Explanation / Answer

#include <iostream>
#include<fstream>
int count=0;
using namespace std;
class vetshop
{
public:
int no_clients;
char animal_name[20];
char animal_breed[20];
char sex;
int owner_id;
int diagnosis_id;
float bill_balance;
void input()
{
cout<<"Enter number of clients";
cin>>no_clients;
while(count<=no_clients)
{
cout<<"Enter name of the animal";
cin>>animal_name;
cout<<"Enter animal breed";
cin>>animal_breed;
cout<<"Enter Gender";
cin>>sex;
cout<<"Enter owner id";
cin>>owner_id;
cout<<"Enter diagnosis id";
cin>>diagnosis_id;
cout<<"Enter bill balance";
cin>>bill_balance;
count++;
}
}
  
  
};
int main()
{
vetshop v;
string l;
ifstream f("vet.txt");
ofstream file("vet.txt");
cout<<"Enter the ANIMAL data into the file";
v.input();
if (file.is_open())
{
file<<v.no_clients<<endl;
file<<v.animal_name<<endl;
file<<v.animal_breed<<endl;
file<<v.sex<<endl;
file<<v.owner_id<<endl;
file<<v.diagnosis_id<<endl;
file.close();
}
else
cout<<"unable to open the file";
cout<<"reading from the file";
if(f.is_open())
{
while(getline(f,l))
{
cout<<l<<endl;
}
f.close();
}

return 0;
}

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