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

Can someone tell me what is wrong with my code??? #include<iostream> #include<fs

ID: 3686285 • Letter: C

Question

Can someone tell me what is wrong with my code???

#include<iostream>

#include<fstream>

#include<string>

using namespace std;

void openFile(ifstream & inFile);

void readArray(ifstream & inFile, double numbers[], int & score);

void determineHighLow(double numbers[], const int SCORES, int count);

void calculateScore(double numbers[], const int SCORES, int count, double high, double low, double total, double sum);

void displayScore(double total);

double high, low, total, sum;

int score;

int main()

{

ifstream inFile;

inFile.open("scores.txt");

int count = 0;

const int SCORES = 8;

double numbers[SCORES];

openFile(inFile);

readArray(inFile, numbers, score);

determineHighLow(numbers, SCORES, count);

calculateScore(numbers, SCORES, count, high, low, total, sum);

displayScore(total);

system("pause");

return 0;

}

void openFile(ifstream & inFile)

{

inFile.open("scores.txt");

if (!inFile)

{

cout << "Can't find the input file" << endl;

system("pause");

exit(-1);

}

}

void readArray(ifstream & inFile, double numbers[], int & score)

{

score = 0;

while (!inFile.eof())

{

inFile >> numbers[score];

score++;

}

}

void determineHighLow(double numbers[], const int SCORES, int count, double high, double low)

{

high = numbers[0];

low = numbers[0];

for (int i = 0; i < count; i++)

{

if (numbers[i] > high)

{

high = numbers[i];

}

else if (numbers[i] < low)

{

low = numbers[i];

}

}

cout << "Dropped Scores " << high << " " << low << endl;

}

void calculateScore(double numbers[], const int SCORES, int count, double high, double low, double total, double sum)

{

sum;

for (int i = 0; i < count; i++)

{

sum = sum + numbers[i];

}

total = sum - high - low;

}

void displayScore(double total)

{

cout << "Received score is " << total << endl;

}

Explanation / Answer

Fixed the compilation issues. Below is the program

#include<iostream>

#include<fstream>

#include<string>

using namespace std;

void openFile(ifstream & inFile);

void readArray(ifstream & inFile, double numbers[], int & score);

void determineHighLow(double numbers[], const int SCORES, int count);

void calculateScore(double numbers[], const int SCORES, int count, double high, double low, double total, double sum);

void displayScore(double total);

double high, low, total, sum;

int score;

int main()

{

ifstream inFile;

inFile.open("scores.txt");

int count = 0;

const int SCORES = 8;

double numbers[SCORES];
openFile(inFile);

readArray(inFile, numbers, score);

determineHighLow(numbers, SCORES, count);

calculateScore(numbers, SCORES, count, high, low, total, sum);

displayScore(total);

system("pause");

return 0;

}

void openFile(ifstream & inFile)

{

inFile.open("scores.txt");

if (!inFile)

{

cout << "Can't find the input file" << endl;

system("pause");

exit(-1);

}

}

void readArray(ifstream & inFile, double numbers[], int & score)

{

score = 0;

while (!inFile.eof())

{

inFile >> numbers[score];

score++;

}

}

void determineHighLow(double numbers[], const int SCORES, int count)

{

double high = numbers[0];

double low = numbers[0];

for (int i = 0; i < count; i++)

{

if (numbers[i] > high)

{

high = numbers[i];

}

else if (numbers[i] < low)

{

low = numbers[i];

}

}

cout << "Dropped Scores " << high << " " << low << endl;

}

void calculateScore(double numbers[], const int SCORES, int count, double high, double low, double total, double sum)

{
sum=0;

for (int i = 0; i < count; i++)

{

sum = sum + numbers[i];

}

total = sum - high - low;

}

void displayScore(double total)

{

cout << "Received score is " << total << endl;

}

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