You may want to start by fixing the errors your compiler is telling you about.
Just a small list to start, many, many more following these.
||=== c++homework, Debug ===|
main.cpp||In function ‘int main()’:|
main.cpp|15|error: invalid conversion from ‘int (*)()’ to ‘int’ [-fpermissive]|
main.cpp|16|error: ‘array1’ was not declared in this scope|
main.cpp|17|error: expected primary-expression before ‘]’ token|
main.cpp|17|error: ‘elems’ was not declared in this scope|
main.cpp|18|error: ‘median1’ was not declared in this scope|
main.cpp||In function ‘int numScores()’:|
main.cpp|29|error: no match for ‘operator>>’ in ‘std::cin >> numScores’|
Code:
#include <iostream>
using namespace std;
int numScores();
float array(int numscores);
void getScores(int numscores,float array1);
void sortArray1(float array1[], int elems);
int binarySearch(float array1, int numScores, float median1);
void outputArray(float array1,int numScores,float median1);
int main()
{
numScores();
array(numScores);
getScores(numScores,array1);
sortArray1(array1[],elems);
binarySearch(array1, numScores,median1);
outputArray(array1,numScores,median1);
system("pause");
return 0;
}
int numScores()
{
do
{
cout << "Please enter how many scores you have to enter: " << endl;
cin >> numScores;
}
while (numScores > 25 || numScores < 5);
return numScores;
}
float array(int numScores)
{
float array1[numScores];
array1=new float*;
if (array1==0)
{
exit(2);
}
return array1;
}
void getScores(int numScores,float array1)
{
for (int i=0;i<numScores;i++)
{
do {
cout << " Please enter your 1st score now: " << endl;
cin >> array[i];
} while (array[i] > 100 && array[i] < 0)
}
}
void sortArray1(float array1[], int elems)
{
bool swap;
float temp;
do
{
swap = false;
for (int count = 0; count < (elems - 1); count++)
{
if (array[count] > array[count + 1])
{
temp = array[count];
array1[count] = array1[count + 1];
array1[count + 1] = temp;
swap = true;
}
}
} while (swap);
}
int binarySearch(array1, int numScores, int median1)
{
int first = 0, // First array element
last = numScores - 1, // Last array element
middle, // Mid point of search
position = -1; // Position of search value
bool found = false; // Flag
while (!found && first <= last)
{
middle = (first + last) / 2; // Calculate mid point
if (array1[middle] == value) // If value is found at mid
{
found = true;
position = middle;
}
}
return position;
}
}
void outputArray(float array1,int numScores,float median1)
{
for(int i=0; i< numScores; i++)
{
cout << array[i] << endl;
cout << middle << endl
}
}
Jim