mean and median for test grade (1-100) students

// I cannot figure out what I need to change.

// I cant get it to count the number of scores it puts in instead it says "enter next score"

// How would you terminate the program if you will. If say you want to enter two test scores? It keep looping through instead of displaying mean and median after I input two scores

// Finally, I cant get "enter -1 to stop" showing up, I know there is a better way to end the program when the user wants

// Thanks for the help




#include <iostream>
#include <conio.h>

using namespace std;

int MaxCal(int*, int count);
int MinCal(int*, int count);
int AvgCal(int*, int count); // MEAN
int MedianCal(int*, int count); //MEDIAN

void getInfo(int*, int);


int main()
{

int input;
int testScores[100];
int count = 0;
int num;
int i;
int*testArray;


std::cout << " How many students took the 2nd MIS 120\n Test? ";
cin >> num;

while (num <= 0 || num > 100)
{
std::cout << " That can't be, You have more than one student and less than 100 in MIS 120\n this semester\n\n ";
cin >> num;

}



{
cout << " Enter Test 1 Score. " << endl;
cin >> input;

}
}


void getInfo(int*testArray[], int count);



int i;

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

{

do

{

std::cout << " Enter Test " << (i + 1) << " Score ";

cin >> testArray[i];

if (testArray[i] < 0 || testArray[i]>100)

std::cout << "Invalid entry, Please enteer a value between 0 and 100\n";

} while (testArray[i] < 0 || testArray[i]>100);



std::cout << "Entered Test scores" << endl << endl; //To display Entered scores
{
for (int i = 0; i < count; i++)
cout << testScores[i] << endl;
} do
{
std::cout << endl;

std::cout << "Max Score : " << MaxCal(testScores, count) << endl;
std::cout << "Min Score : " << MinCal(testScores, count) << endl;
std:cout << "Avg Score : " << AvgCal(testScores, count) << endl;
std::cout << "Median Score : " << MedianCal(testScores, count) << endl;
_getch();

}
}
}
}
}

int MaxCal(int* testArray, int count) //To calculate Max Score
{
int max = testArray[0];
for (int i = 1; i<count; i++)
{


if (max<testArray[i])
max = testArray[i];


}
return max;
}

int MinCal(int* testArray, int count) //To calculate Min Score
{
int min = testArray[0];
for (int i = 1; i<count; i++)
{


if (min>testArray[i])
min = testArray[i];


}
return min;
}

int AvgCal(int* testArray, int count) //To calculate Avg Score
{
int avg = 0;
for (int i = 0; i<count; i++)
{
avg += testArray[i];
}

avg = avg / count;

return avg;
}

int MedianCal(int* testArray, int count) // To calculate Median Score
{
int m1, m2;

if (count % 2 == 0)

{

m1 = count / 2;

m2 = (count / 2) - 1;

return((*(testArray + m1) + *(testArray + m2)) / 2.);

}

else

return *(testArray + (count / 2));

}
Topic archived. No new replies allowed.