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

Everything except for global constants must be pointers for this problem. C++ on

ID: 3669562 • Letter: E

Question

Everything except for global constants must be pointers for this problem.
C++ only
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 th arrays must be dynamic arravs. Your program should have A function that reads in the donation data from the file and stores it into an arra 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 callin 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 A function that displays the following: . Number of donations 1-3 4-6 7-9 10-12 13-15 16+ Category: 1) 2) The number of donors. The largest number of pints Plasma Pals Carotid Club Artery Amigos Sanguine Superstars Dynamite Donors LifeSavers donated by a single donor. 3) The average donated by individuals to 2 digits of precision 4) 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 ach 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 declar stream! That should be done in the function that reads the data from the file stores it in the array

Explanation / Answer

/* This function reads the file called from the main program and return the list back to main.

string read(string fname, string** list, int len){
*list = new string[len];
ifstream file(fname);
string line;
for (int i = 0; i < len; i++){
getline(file, line);
*(*list + i) = line;
}

file.close();
return **list;
}
  
/* This program finds the largerst number in the array.

void large(int *list[],int num[],int n){
for(int i=1;i<n;++i) /* Loop to store largest number at address data */
{
if(*list<*(list+i))
*list=*(list+i);
}
cout<<"Largest element = "<<*list;
return 0;
}

/*This returns the sum and the average of the value passed to the function.

void average(int *list[],int num[],int n){
int sum=0;
double avg=0.0;
for(int i=0; i<n; ++i)
{   
sum+=*list[i];
}
avg=sum/n;

}

/* This is the main function which calls the function that have been defined above.
int main()
{
int *list[],*num[],n; // Here the list and the num arrays are the respective arrays.
fstream file;
cout<<"Enter the size of the list";
cin>>n;
file.open("demo.txt"); //This is the text file that you want the program to read.
read(fname,list,n);
large(list,num,n);
avg(list,num,n);
}

The 5th part has not been covered here.This is what I could get for the remaining parts.
Hope this works for you.

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