I need some serious help.. I can't get it to work..Code:#include <iostream> #include <cassert> #include <fstream> #include <string> #include <iomanip> using namespace std; //Function Prototypes. void openFiles(ifstream& infile); void getData(ifstream& infile,int scores []); double calcScore(const int scores [], double average); void display(ifstream& infile, const int [], double average); const int arraySize = 11; int main () { int scores[arraySize]; ifstream infile; double average; openFiles(infile); getData(infile, scores); average = calcScore(scores, average); display(infile, scores, average); return 0; } //Asking user to enter file name. Then opening the file. void openFiles(ifstream& infile) { string infilename; cout <<"Enter the file name to open"<< endl; cin >> infilename; infile.open(infilename.c_str()); assert(infile); } //Getting scores from the file they put in. void getData(ifstream& infile, int scores[]) { int i=0; while (infile) { infile >> scores[i]; i++; } } //Calculating the scores to keep in. double calcScore(const int scores []) { int sum = 0; for (int i = 0; i < scores; i++) sum += scores[i]; return sum / static_cast<double>(); } //Displaying the points reveived by contestant. void display(const int scores[]) { cout << fixed << showpoint << setprecision(2); cout << endl << "Scores:" << endl; for (int i = 0; i < scores; i++) cout << setw(7) << scores[i] << endl; cout << endl << "Average: " << average << endl; }
The objective of the project is to be able to use declare, use and manipulate arrays. In a gymnastics or diving competition, each contestant's score is calculatede by dropping the lowest and highest scores and then addign the remaining scores. A judge awards point between 1 and 10, with 1 being the lowest and 10 being the highest. im supposed to write a program that read in the judges scores from an input file(their will be between 5 and 10 scores) and output the points received by the contestant, formatted with two decimal places.
Help?



LinkBack URL
About LinkBacks


