Question
Please provide beginner level C++ code based on the given instructions ** Cannot use .sort , must write a sorting algoriithm. I have a sample
Please provide beginner level C++ code based on the given instructions **Cannot use .sort, must write a sorting algoriithm. I have a sample of the algorithm in my notes which I can post if it would help. The assignment instructions, the main class, and two text files are included below. THANK YOU!! If there's anything else I can provide or change to help out, let me know in the comments!
MAIN:
const int MAXSIZE = 150;
int main()
{
int nums[MAXSIZE];;
int numElements;
int total;
double average;
int multiplesOf;
int numMultiples;
double median;
// Change the statement below to print your name
cout
// Call the loadArray function
cout
// Call the function printArray
// Call the function totalOfAllNumbers
cout
// Call the function averageOfArray;
cout
cout
cin >> multiplesOf;
// Call the function countMultiplesOf;
cout
cout
// Call the function printArray
// Call the function sortArray
cout
// Call the function printArray
// Call the function findMedianOfNumbers
cout
return 0;
}
2 TEXT FILES:
randomA.txt
63 -59 -54 14 51 5 88 23 -87 -77 68 -30 -8 -76 -57 30 85
randomB.txt
-42 -92 82 -38 55 20 -61 2 77 -13 -22 -51 19 85 -97 -41 -88 9 -74 -18 7 43 51 36 96 -71 -52 17 -91 -34 -49 -33 31 -41 -72 -23 5 -71 87 46 93 -32 57 66 -34 -7 3 16 -2 -27 11 5 16 -59 -42 7 -28 41 -87 -90 70 66 6 -33 73 -64 -86 42 54 -4 24 -48 73 11 72 71 -9 49 -95 -79 -29 -37 92 -43 64 23 -34 -36 16 85 -51 -47 65 100 90 21 -50 -20 -29 76 -1 -34 60 -85
SAMPLE OUTPUTS:
main - a main function has been given. You are to only add the function calls. The comments will tell you where the function calls should be done. Do NOT change main. The following functions should be implemented loadArray This function has an array and a variable to count the number of elements in the array passed into it. The function asks the user for the file name, opens the file with the filename and reads the numbers into the array. It also keeps track of how many numbers are in the array. It makes sure the file opens correctly and if it doesn't, it exits the program. This method should also check to make sure that more than the MAXSIZE values are not put into the array printArray this function is passed an array and the number of values in the array. It then prints average Array this function is passed an array and the number of values in the array. It returns sortArray sorts the numbers in the array. It is passed the array and the number of values in the countMultiplesOf this function is passed an array, the number of values in the array, and the the values in the array, eight per line as shown in the output the average of the numbers in the array array number that the function is counting the multiples of. For example, if a five is passed in, this function will count all the multiples of five in the array totalOfNumbers this function is passed an array and the number of values in the array. It returns the total of the numbers in the array findMedian this function is passed an array and the number of values in the array. It returns the s in the array. If there are an odd number of elements in the array, the median of the number median is the middle number (ex: the median of 1, 2, 3, 4,5 is 3). If there is an even number of elements in the array, the median is the average of the middle 2 numbers. (ex: the median of 1 2, 3, 4 is 2.5) There is NO loop in this method
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started