### Calculating sum, max, and min values in an array?

My professor has approved all the functions until findmax onward- I wrote those after class so they haven't been checked.

I have to calculate and display the sum of the values in the array (all representing scores for a performance), excluding the minimum and maximum values. Can somebody check over my findmax and findmin functions, and help me with the calcdisplay function?

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081`` ``````#include #include #include #include using namespace std; void openfile(ifstream& infilename); void getscores(double scores[], ifstream& infile, int& size); void findmax(double scores[], ifstream& infile, int size, double& max); void findmin(double scores[], ifstream& infile, int size, double& min); //Call all functions and display data. int main() { ifstream infile; double scores[15], min, max, sum; int size; openfile(infile); getscores(scores, infile, size); findmax(scores, infile, size, max); findmin(scores, infile, size, min); system("pause"); return 0; } //Locate and open the input file. void openfile(ifstream& infile) { string infilename; cout << "Enter the name of the input file: "; cin >> infilename; infile.open(infilename); assert(infile); } //Get scores from user, store in file void getscores(double scores[], ifstream& infile, int& size) { int i = 0; do { infile >> scores[i]; i++; } while (infile); size = i - 1; } //Find the highest score. void findmax(double scores[], ifstream& infile, int size, double& max) { double max = scores[0]; for (int i = 0; i < size; i++) if (scores[i] > max) max = scores[i]; } //Find the lowest score. void findmin(double scores[], ifstream& infile, int size, double& min) { double min = scores[0]; for (int i = 1; i < size; i++) if (scores[i] > min) min = scores[i]; } //Display all scores, dropped scores, and sum of remaining scores. void calcdisplay(double scores[], ifstream& infile, int size, double max, double min, double& sum) { }``````
Topic archived. No new replies allowed.