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

can anyone help me with the program? thank you for your help. You have been aske

ID: 3669738 • Letter: C

Question

can anyone help me with the program? thank you for your help.

You have been asked to develop a program that allows the local Red Cross organization to view stats regarding blood donations. A different computer program has generated a file that consists of a collection of integers representing the number of pints donated by individual donors over the past 2 years. The file is named “donations.txt”, and you have no idea how many numbers are in it. The size of the donor array must be just large enough to hold the donors with none left out and no unused space.

You must use pointers for every variable except the file stream. This means that both arrays must be dynamic arrays.

Your program should have:

A function that reads in the donation data from the file and stores it into an array. The array must be accepted as a parameter. You must keep track of how many donors are in the file. Make sure the number of donors is delivered to the calling function so that that function knows how many donors were in the file.

A function that returns the largest number found in the array. This represents the largest number of donations given by a donor, or donors in the case of several donors having the largest number. Remember to pass both the array and the number of donors to this function.

A function that calculates and returns the average number of donations in the array. This average should be given as a double. Remember to pass both the array and the number of donors to this function.

A function that puts donors into one of 6 categories according to how many donations they have made. The categories are listed in the table. This function should accept the array of donors and the number of donors plus an array that stores the number of donors that fall into each category.

Number of donations:

Category:

1-3

Plasma Pals

4-6

Carotid Club

7-9

Artery Amigos

10-12

Sanguine Superstars

13-15

Dynamite Donors

16+

LifeSavers

A function that displays the following:

The number of donors.

The largest number of pints donated by a single donor.

The average donated by individuals to 2 digits of precision.

A table that displays the number of donors in each category plus the percentage of donors in that category to 2 digits of precision.

This function must accept all of these data as parameters except the percentage of donors in each category, which it can calculate as it displays.

A main function that declares the arrays for the donations and number of donors in each category, plus variables to store all other relevant data.   The main function should call all of the other functions in the proper order. It should NOT declare a file stream! That should be done in the function that reads the data from the file and stores it in the array.

Number of donations:

Category:

1-3

Plasma Pals

4-6

Carotid Club

7-9

Artery Amigos

10-12

Sanguine Superstars

13-15

Dynamite Donors

16+

LifeSavers

Explanation / Answer

#include<iostream.h>
#include<conio.h>
#include<string.h>

class donor
{
   private:
       char name[20],sex[20],blood_grp[20];
      
       int donor_no[20], age[10],i, n, ch;
   public:
       void getdata();
       void display();
};

   void donor::getdata()
   {
   cout<<" category details would u like to enter : " ;
   cin>>n;
   for(i=0;i<n;i++)
   { cout<<"NUMBER OF DONATIONS : ";
   cin>>donor_no[i];
   cout<<"DONOR NAME : ";
   cin>>name[i];
   cout<<"DONOR AGE : ";
   cin>>age[i];
   cout<<"CATEGORY OF DONORS : ";
   cin>>category[i];
  
cout<<"DONOR BLOOD GROUP: ";
   cin>>blood_grp[i];
   }
}
   void donor::display()
   {
   cout<<" DONOR DETAILS ";
   cout<<" -----------------------";
   cout<<" 1. NUMBER OF DONORS :";
  
   cout<<" 2. EXIT ";
   cout<<" Enter your Choice : ";
   cin>>ch;
   switch(ch)
   {
   case 1: cout<<" NUMBER OF DONORS IN BETWEEN 1-3";
       cout<<" --------------------------";
       for(i=0;i<n;i++)
       {
       if(number of donors='1-3')
       {
       cout<<" "<<plasma pals<<number of donors;
       }
       else
       cout<<"return to category";
       break;
       }

   case 2:
       cout<<" NUMBER OF DONORS IN BETWEEN 4-6";
       cout<<" --------------------------";
       for(i=0;i<n;i++)
       {
       if(number of donors='4-6')
       {
       cout<<CARROTID CLUB<<number of donors;
       }
       else break;
       }

   case 3:

       cout<<" IF NUMBER OF DONORS IN BETWEEN 7-9";;
       cout<<" --------------------------";
       for(i=0;i<n;i++)
       {
       if(number of donors='7-9')
       {
cout<<ARTERY AMIGOS<<number of donors;
       }
}
       break;}

case 4:

       cout<<" IF NUMBER OF DONORS IN BETWEEN 10-12";;
       cout<<" --------------------------";
       for(i=0;i<n;i++)
       {
       if(number of donors='10-12')
       {
cout<<SANGUINE SUPERSTARS<<number of donors;
       }
}
       break;}
  
case 5:

       cout<<" IF NUMBER OF DONORS IN BETWEEN 13-15";;
       cout<<" --------------------------";
       for(i=0;i<n;i++)
       {
       if(number of donors='13-15')
       {
cout<<DYNAMITE DONORS<<number of donors;
       }
}
       break;}

case 6:

       cout<<" IF NUMBER OF DONORS ARE ABOVE 16";;
       cout<<" --------------------------";
       for(i=0;i<n;i++)
       {
       if(number of donors='16+')
       {
cout<<LIFE SAVERS<<number of donors;
       }
}
       break;}

case 7:

break;
}
}


void main()
{
clrscr();
donor obj;
obj.getdata();
obj.display();
getch();
}

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