Thread: A challenge program

  1. #1
    Registered User alice's Avatar
    Join Date
    Mar 2004
    Posts
    36

    A challenge program

    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);

  2. #2
    Registered User
    Join Date
    May 2004
    Posts
    127
    >Any expert can do this difficult question?
    It isn't a difficult problem, but yes, I'm fully capable of solving it.

  3. #3
    Obsessed with C chrismiceli's Avatar
    Join Date
    Jan 2003
    Posts
    501
    here is what I probably would do, I would have a Linked list of donors, and each one of them would have a field which points a list of donations, each donation would be a structure, telling the amount and any other necessary information, then it is just simple algorithms.
    Help populate a c/c++ help irc channel
    server: irc://irc.efnet.net
    channel: #c

  4. #4
    Registered User alice's Avatar
    Join Date
    Mar 2004
    Posts
    36
    can someone show me how to solve the question...
    thk a lot..

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You do know how to loop through an array don't you? That's all you need for this program, a for loop. This entire program can be solved with only for loops. It's nothing complex.

    Oh, by the way, no, no one here will do your program for you. You have made no effort. Read the nice little Announcements at the top of the board.

    Now read them again.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can someome help me with a program please?
    By WinterInChicago in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2006, 10:58 PM
  2. Need help with my program...
    By Noah in forum C Programming
    Replies: 2
    Last Post: 03-11-2006, 07:49 PM
  3. Help - Program Challenge for C Buffs
    By hern in forum C Programming
    Replies: 4
    Last Post: 04-20-2004, 08:13 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM