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

can anyone help me this this program. Here is what is asked: Write a program tha

ID: 3570534 • Letter: C

Question

can anyone help me this this program.

Here is what is asked:

Write a program that prompts the user to enter the number of elements and the numbers themselves to be placed in an integer array that holds a maximum of 50 elements. The program should then prompt the user for an integer which will be searched for in the array using a binary search. Make sure to include the fol- lowing steps along the way:

i) A sort routine must be called before the binary search. You may use either the selection sort or the bubble sort. However, the sort must be imple- mented in its own function and not in main.

ii) Next include a function called by main to implement the binary search.

The ordered array produced by the sort should be passed to the search routine which returns the location in the sorted array of the sought value, or -1 if the value is not in the array.

iii) Add a value returning function that computes the mean of your data set.

Recall that the mean is the sum of the data values divided by the number of pieces of data. Your program should output the size of the array entered, the array as entered by the user, the sorted array, the integer being searched for, the location of that integer in the sorted array (or an appropriate message if it is not in the array), and the mean of the data set.

iv) (Optional) Modify your program so that the data is entered from a file rather than from the keyboard. The first line of the file should be the size of the integer array. The second line should contain the integer searched for in the data set. Finally, the array elements are to start on the third line. Make sure you separate each array element with a space. The output, as described in iii), should be sent to a file.

Here is what i have so far:

//Write a program that prompts the user to enter the number of elements and the numbers
//themselves to be placed in an integer array that holds a maximum of 50 elements.
//The program should then prompt the user for an integer which will be searched for
//in the array using a binary search.

#include <iostream>
using namespace std;
int binarySearch (const int [], int, int); // pg 456
const int SIZE = 50;
double elements;
double numbers;
double integer;
int results;
void selectionSort (const int [], int, int);//pg 471

int main()
{
int Elements [SIZE] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
        21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
        39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50};//ascending for binary search to work properly.
       
int results;

cout << " how many elements do you have? " << endl;
cin >> elements;
if (elements <= -1 || elements > 50)
cout << "that number is invalid, please enter a number between 0 and 50 " << endl;

cout << " how many numbers do you have? " << endl;
cin >> numbers;
if (numbers <= -1 || numbers > 50)
cout << "that number is invalid, please enter a number between 0 and 50 " << endl;

cout << " Please enter the integer which will be searched in binary! " << endl;
cin >> integer;

void selectionSort(int SIZE[], int integers);

results = binarySearch (SIZE, Elements, numbers); // invalid conversion from int* to int [-fpermissive]
if (integer <= -1 || integer > 50)
cout << "that number is invalid, please enter a number between 0 and 50 " << endl;

return 0;
}
{
int first = 0;
middle;
last = 50;
bool found = false;
while (middle = (first + last0) / 2;
if (array[middle] == integer)
{
found = true;
position = middle;
}

{

else if (array[middle] > integer)
last = middle
else
first = middle
}
return position;




}

Please help, thanks!

Explanation / Answer

c++

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote