Question: SOURCE FILE: #include ///cin, cout #include /// istringstream #include /// pow, sqrt int main() { std::string input; int counter=0; int inum=0; double mean=0.0; double mode=0.0;



SOURCE FILE:
#include///cin, cout #include /// istringstream #include /// pow, sqrt int main() { std::string input; int counter=0; int inum=0; double mean=0.0; double mode=0.0; double median=0.0; double stddev=0.0; int i,j,temp; ///take a set of numbers as string input std::cout>inum){ counter++; } ///clear the flags on the string stream and refill with the input string ss.clear(); ss.str(input); ///create array of size counter(the number of integers) and fill it from the string stream int intArray[counter]; for( i=0; i >inum; intArray[i]=inum; } ///sort the numbers in the array smallest to largest for( i=1; iintArray[j+1]){ temp=intArray[j]; intArray[j]=intArray[j+1]; intArray[j+1]=temp; } } } ///calculate the mean of the numbers for(i=0; i maxi){ maxi=mocount; mode=intArray[i]; modefound=true; } else if(mocount==maxi){ modefound=false; } } else{ if(mocount>maxi){ maxi=mocount; mode=intArray[i]; modefound=true; } mocount=1; temp=intArray[i]; } } ///calculate the standard deviation double sum=0.0; double avg=0.0; for(i=0; i Objectives: The main objective of this assignment is to help you review some of the concepts related to functions in C++ as well as working with files. General Instructions: 1. 2. 3. 4. 5. Read the Problem Descriptions below In this assignment, you will be given a working program. Split the main function given into multiple functions Read input from a file instead of standard in Files provided for this assignment can be found on Blackboard. Task Description: The program in statistics_given.cpp calculates the mean, median, mode and standard deviation of a given set of integers. As it is given, the set of integers is taken from standard in as a string, which is then parsed using stringstream to count the number of integers in the string and insert them into an array The program in statistics_given.cpp file works, but i is all crammed into the main function. As a consequence, a lot of code gets repeated, and the overall logic of the program is hidden by the mass of details Rewrite the program by grouping the code into functions. Change the progr from a file 'input.txt instead of the terminal. In particular, your program should include the following functions am so it takes the input 1. A void function named readFile. The parameter should be a string passed by reference. This function reads a set of numbers from a text file as a single string. 2. A function named countInt that returns an integer. The parameter should be one string containing the set of numbers taken from the file and counts the integers in the string 3. A function named fillArray that takes a string, an integer array, and the arrays size as parameters and returns nothing. This function fills the integer array with the integers from a string Query: are arrays passed by reference automatically? 4. A function named bubbleSort that returns nothing (void). The parameter should be an integer array and its size. The array is sorted by the function
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
