Write a c++ program that develops a class called \"statistic\" that will do some
ID: 667145 • Letter: W
Question
Write a c++ program that develops a class called "statistic" that will do some simple statistical calculations. The program will allow you to add new value(s) to a collection of data and then be able to print out information about the data. For example, how many values are in the set of data (length), the average for the set of data, the largest, smallest values, and the sum of values? You will NOT need to save the individual elements of the data collection, just the values indicated.
Your main program will need to be able to declare an object (ex stat) and then add data elements to this object. For example you may add new values "stat.add( 5.5)", then "stat.add(6.6)" and so on. The class object "stat" will accumulate a sum, count the new element, determine if this is a larger value, and determine if new value is a smaller value. (Again, you will not save the individual elements.) You will then be asking to print out information about the statistical object (number of values, average, smallest value in collection, largest value, and the sum.
Methods needed for the "statistic" are: add, getlength, getsum, getaverage, getlargest, getsmallest, initstat.
The methods should be self explanatory. "initstat" will set a statistical object to zero so as to accumulate a new collection.
Use the following input to test you program.
Data for statistician1: 5.5, 6.6, 8.8, -3.4, -0.5, 4.7, 9.1
Print out: the Sum, length and average
add to statistician1: 5.2 - 3.3 - 8.5 3.2 5.5
Print out: the Average, the smallest and largest values
Data for statistician2: empty
Print out: the Sum, length and average
add to statistician2: 103 821 871 487 312 245 224 623 424 432
Print out: the Sum, length and average
Erase statistician2:
Data for Statistician2: 9.3 -6.3 8.2 7.2 8.2 8.8 7.2 -3.2 7.6 9.3
Print out: the Sum, length and average
Print out: the Average, the smallest and largest values
Explanation / Answer
Hi,
Is it okay if i implement this taking input from a file????
Please let me know.
Thanks,
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.