My output doesn't match locals

Hello all! I need help with my findHigest and findLowest. In the locale it is listing the right numbers but I can't get the output to match what the locale has. Do I have my wording wrong?

<code>

#include <iostream>
#include <cmath>
#include <iomanip>
#include <fstream>
#include <string>
#include <sstream>

using namespace std;

void loadArrays(int playerNum[], int atBat[], int hits[], int runs[], int rbi[], int& count) {
string line;
ifstream iFile;
iFile.open("C:\\Users\\Jessica\\Desktop\\CIS 1202\\Baseball Stats\\Debug\\baseball.txt"); // text document location, open the text file
while (getline(iFile, line)) // get the lines of the text
{
istringstream iss(line);
int n;
// read intergers from a file
iss >> n;
playerNum[count] = n;
iss >> n;
atBat[count] = n;
iss >> n;
hits[count] = n;
iss >> n;
runs[count] = n;
iss >> n;
rbi[count] = n;
count++;
}
}
void calBatAvg(int hits[], int atBat[], int batAvg[], int count, int &teamBatAvg)
{
int teamAtBat=0, teamHits = 0;
for (int i = 0; i < count; i++) // "resetting it each time, a number of times, and doing each line in the text tile
{
// formula for batting average and i is pulling number for the arrays
batAvg[i] = (int)round((double)hits[i] / (double)atBat[i] * 1000);
teamAtBat += atBat[i]; // adds all of the at bats from the arrays
teamHits += hits[i]; // adds all the hits from the arrays

}
teamBatAvg= (int)round((double)teamHits / (double)teamAtBat * 1000); // not in the array

}
void printStats(int playerNum[], int atBat[], int hits[], int runs[], int rbi[], int batAvg[], int count) {

string comment;

cout << left << setw(10) << "Player Num";
cout << " ";
cout << left << setw(7) << "At Bats";
cout << " ";
cout << left << setw(4) << "Hits";
cout << " ";
cout << left << setw(4) << "Runs";
cout << " ";
cout << left << setw(4) << "RBIs";
cout << " ";
cout << left << setw(7) << "Bat Avg";
cout << " ";
cout << left << setw(13) << "Comment" << endl;

for (int i = 0; i < count; i++)
{
if (batAvg[i] > 0 && batAvg[i] <= 299)
{
comment = "Little League";
}
if (batAvg[i] > 300 && batAvg[i] <= 499)
{
comment = "Farm League";
}
if (batAvg[i] > 499 && batAvg[i] <= 1000)
{
comment = "World Series";
}
cout << left << setw(10) << playerNum[i];
cout << " ";
cout << left << setw(7) << atBat[i];
cout << " ";
cout << left << setw(4) << hits[i];
cout << " ";
cout << left << setw(4) << runs[i];
cout << " ";
cout << left << setw(4) << rbi[i];
cout << " ";
cout << left << setw(7) << batAvg[i];
cout << " ";
cout << left << setw(13) << comment << endl;

}
}
void findHighest(int batAvg[],int hits[], int runs[], int count) {
int highest;
highest = batAvg[0];
for (int i = 0; i < count; i++)
{
if (batAvg[i] > highest)
highest = batAvg[i];
}
}
void findLowest(int batAvg[], int hits[], int runs[], int count) {
int lowest;
lowest = batAvg[0];
for (int i = 0; i < count; i++)
{
if (batAvg[i] < lowest)
lowest = batAvg[i];
}
}
int main()
{
// functions
int teamBatAvg;
const int SIZE = 20;
int playerNum[SIZE], atBats[SIZE], hits[SIZE], runs[SIZE], RBIS[SIZE], batAvg[SIZE], numberOfPlayers;
int count = 0;
int numbers[SIZE];
ifstream baseballStats;
loadArrays(playerNum, atBats, hits, runs, RBIS, count);
calBatAvg(hits, atBats, batAvg, count,teamBatAvg);
findHighest(batAvg, hits, runs, count);
findLowest(batAvg, hits, runs, count);
printStats(playerNum, atBats, hits, runs, RBIS, batAvg, count);

cout << "The Team Batting Average is: " << teamBatAvg << endl;
cout << "The Best Player is Player Number: " << findHighest << endl;
cout << "The Worst Player is Player Number: " << findLowest << endl;
}
> cout << "The Best Player is Player Number: " << findHighest << endl;
you are not calling the function there.
and your function returns nothing, so don't know what you are trying to print then.
Topic archived. No new replies allowed.