Question: Could someone help me to JUST COMPLETE my code below please. The assignment asks that we have seperate header and cpp files it just wont

Could someone help me to JUST COMPLETE my code below please. The assignment asks that we have seperate header and cpp files it just wont compile right.

Could someone help me to JUST COMPLETE my code below please. The

My code so far

main.cpp

#include #include #include "search.h" #include "sort.hh" #include "statistics.hh"

using namespace std;

//Function prototypes void data(int[],int);

int main() { //Declare variables int t,num,elements[50],key;

//Prompt and read input from the user cout>num;

while(num>50) { cout>num; }

//Call the methods data(elements,num); Display(elements,num,"unsorted"); sortArray(elements,num); Display(elements,num,"sorted");

cout>key;

t=binarySearch(elements,num,key); if(t

sort.cpp

#include #include #include "sort.hh" using namespace std;

void Display(int elements[],int n,string d) { int i; cout

void sortArray (int elements[], int size) { bool swap; int temp;

do { swap=false; for (int count =0; count elements[count+1]) { temp = elements[count]; elements[count]=elements[count+1]; elements[count+1]=temp; swap=true; } } } while (swap); }

sort.hh

#ifndef _SORT_HH_INCLUDED // is myheader.h already included? #define _SORT_HH_INCLUDED // define this so we know it's included

using namespace std; //Function prototypes void sortArray(int[],int); void Display(int[],int,string);

#endif

search.cpp

#include #include #include "search.h"

int binarySearch(int[],int,int);

#include #include using namespace std;

int binarySearch(int elements[], int size, int value) { int first=0, last = size-1, middle, position = -1; bool found =false;

while (!found && first value) last - middle-1; else first = middle +1; } return position;

}

search.h

#ifndef _SEARCH_H_INCLUDED // is myheader.h already included? #define _SEARCH_H_INCLUDED // define this so we know it's included //Function prototypes

int binarySearch(int[],int,int);

#endif

statistics.cpp

#include #include #include "statistics.hh"

//Method definition of mean: Recall that the mean is //the sum of the data values divided by the number //of pieces of data.

double mean(int elements[],int n) { int i,sum=0; for(i=0;i

statistics.hh

#ifndef _STATS_HH_INCLUDED // is myheader.h already included? #define _STATS_HH_INCLUDED // define this so we know it's included //Function prototypes

double mean(int[],int);

#endif

Write a program that prompts the user to enter the number of elements and the numbers themselves to be placed in an dynamic integer array that holds a maximum of 50 elements. (Do not forget to validate!!) - then prompts the user for an integer which will be searched for in the search. Make sure to include the following steps array using a binary 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 implemented in its own function and its own implementation file called "sort.cpp". Write the appropriate header in "sort.hh" Next include a function called by main to implement the binary search. This function should be implemented in a file called "search.cpp", with a header in "search.hh". 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, in a implementation file/header file called "statistics.cpp" and "statistics.hh" 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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!