Any expert can do this difficult question?
You have joined a small software company as a junior programmer. The company mainly takes in software development jobs for small and medium enterprises. A charity body has
contracted the company to develop a system that handles donor relations. Part of the system is on keeping donation records of the donors for promotional and marketing purposes.
You are given the task of designing and implementing a component for keeping donation records. Your component will receive and supply data to other components; therefore you
spent a lot of time liaising with other programmers on their requirements. The following lists the functionality required of your component.
* Records a donation record.
* Gets the total amount of donation made by a donor.
* Gets the number of donations made by a donor.
* Gets the top five donors in the amount of donation made.
* Prints the donor list in an order of amount of donation made.
You have decided to design an Abstract Data Type for keeping donation records. Your task
now is to implement the functions for the ADT.
Data Part
The following shows the declaration of data structures for the ADT.
Code:
#define MAX_DONORS 256
struct donorrecord {
char name[256]; /* name of donor */
float totalAmount; /* total amount of donation made */
int frequency; /* total number of donation made */ };
typedef struct donorrecord DonorRecord;
struct donationrecord {
DonorRecord donor[MAX_DONORS]; /* an array of donor records */
int count; /* number of donor records actually used */ };
typedef struct donationrecord DonationRecord;
Implement the following ADT functions for the Donation Record ADT.
Code:
/* This function adds the given donation record to the ADT */
void addDonation(DonationRecord* drecord, char* name, float amount);
/* This function returns the total amount of donation made by donor
name */
float getDonationAmount(DonationRecord* drecord, char* name);
/* This function saves all the donation records in the ADT to the given
filename */
/* Returns 1 if successful, 0 if failed */
int saveDonationRecord(DonationRecord* drecord, char* filename);
/* This function loads all the donation records in the ADT from the
given filename */
/* Returns 1 if successful, 0 if failed */
int loadDonationRecord(DonationRecord* drecord, char* filename);
/* This function returns the donor record whose donation amount is
at the top */
DonorRecord* getTopDonor(DonationRecord* drecord);
/* This function sorts the donation records using the given order on
the total donation amount in ascending order */
void sortDonationRecord(DonationRecord* drecord, int order);