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

must use code blocks c++ Write a program that meets the following requirements:

ID: 3738678 • Letter: M

Question

must use code blocks c++

Write a program that meets the following requirements:

This assignment is to demonstrate the use of FUNCTIONS and ARRAYS.

Write a program that meets the following requirements:

1. Read in a maximum of 50 records, each record will be on a separate line using columns one and two.

           Example:

           36

           O1

           5H

       

2. Determine if each record is a positive integer. Keep track of all records that are not positive integers and print a list of them.

For all the positive integer data records:

3. Determine the average (mean) rounded to the nearest whole number, median, mode and standard deviation.

4. Compute the difference between each of the positive integers and the mean and store the difference in an array corresponding to the original integer number.

5. Determine which of the integers deviate’s the most from the mean, print the number and how much it deviates.

6. Print the original list of integers along side the list of integers sorted from the lowest to the highest.

7. Print a bar graph indicating how much each integer deviates from the mean. Use the sorted list of integers to develop the graph.

8. Label and print all of the above findings.

Your program must have separate functions to determine each of the following: mean, median, mode, standard deviation, reading of the original data, printing of the invalid records, printing of the valid records, number 6 and 7 above.

Your program will have its final test with the integers from the data file data6.txt.

Demonstrate your output in lab.

Submit your source code and algorithm or flowchart in blackboard.

All values must be clearly labeled in the output.

You are required to demonstrate your output in Lab.

Documentation will be 20% of your grade.

Your source code must contain the following documentation.

Header information: (Source Code and Output)

        Your Name, course & section number, assignment number and due date.

A brief description of your assignment.

Variable dictionary: A brief description of every variable used in your program.

Comments related to input and output of data and all formulas used in your code.

data6.txt

shell

Explanation / Answer

#include <iostream>

using namespace std;

void mode(int[], int); // write this outside main as it's function declaration
void mean(int[], int); // write this outside main
void sort(int[], int); // write this outside main
void median(int[], int); // write this outside main
void calculateSD(int[],float,int);

int main()
{


//include this part inside main and make a function calls from main()

float total, mode;
int n = (sizeof(good)/sizeof(*good));//number of elements in array
int array[n];
//fill in the value of array
for(int i=0; i<n; i++){
cout << "fill in the "<< i+1 << " number. :";
cin >> array[i];
}

sort(array, n);
return 0;
}
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////

//// write this outside main
void mean(int new_array[], int num){
//GET TOTAL & CALCULATE MEAN
float total = 0.0f;
for(int i=0;i<num; i++){
total += new_array[i];
}
cout << "The mean is " << total/num << endl;
calculateSD(new_array, total/num, num);
  
}
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////

//// write this outside main

void median(int new_array[], int num){
//CALCULATE THE MEDIAN (middle number)
if(num % 2 != 0){// is the # of elements odd?
int temp = ((num+1)/2)-1;
cout << "The median is " << new_array[temp] << endl;
}
else{// then it's even! :)
cout << "The median is "<< new_array[(num/2)-1] << " and " << new_array[num/2] << endl;
}
mean(new_array, num);
}
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////

//// write this outside main


void mode(int new_array[], int num) {
int* ipRepetition = new int[num];
// alocate a new array in memory of the same size (round about way of defining number of elements by a variable)
for (int i = 0; i < num; i++) {
ipRepetition[i] = 0;//initialize each element to 0
int j = 0;//
while ((j < i) && (new_array[i] != new_array[j])) {
if (new_array[i] != new_array[j]) {
j++;
}
}
(ipRepetition[j])++;
}
int iMaxRepeat = 0;
for (int i = 1; i < num; i++) {
if (ipRepetition[i] > ipRepetition[iMaxRepeat]) {
iMaxRepeat = i;
}
}
cout<< "The mode is " << new_array[iMaxRepeat] << endl;

}
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////


//// write this outside main

void sort(int new_array[], int num){
//ARRANGE VALUES
for(int x=0; x<num; x++){
for(int y=0; y<num-1; y++){
if(new_array[y]>new_array[y+1]){
int temp = new_array[y+1];
new_array[y+1] = new_array[y];
new_array[y] = temp;
}
}
}
cout << "List: ";
for(int i =0; i<num; i++){
cout << new_array[i] << " ";
}
cout << " ";
median(new_array, num);
}

//rite this outside main() hich is to calculate standard deviation

float calculateSD(float data[], float mean , int num)
{
float sum = 0.0, standardDeviation = 0.0;

int i;

for(i = 0; i < 10; ++i)
{
sum += data[i];
}

mean = sum/10;

for(i = 0; i < 10; ++i)
standardDeviation += pow(data[i] - mean, 2);

cout << "The standard deviation is " << sqrt(standardDeviation / 10)<<endl;
mode(data, num);
}

// Bar graph can be created using

Here