#!/usr/bin/perl -w

# stats2.pl
# This program uses Stats2.pm to print out some assorted 
# statistics on the input numbers

use Stats2;

# Catch Ctrl-C (SIGINT signal)
$SIG{'INT'} = 'getResults';

my $obj = new Stats2;

sub getResults {
	print "\n\nResults ==============================\n";
	print "Number of values: ", scalar($obj->getValueList()), "\n";
	print "Minimum: ", $obj->getMinimum(), "\n";
	print "Maximum: ", $obj->getMaximum(), "\n";
	print "Total: ", $obj->getTotal(), "\n";
	print "Mean: ", $obj->getMean(), "\n";
	print "Standard Deviation: ", $obj->getStdDev(), "\n";
	print "Variance: ", $obj->getVariance(), "\n";
	exit (0);
}

print qq~
Statistics Calculator
Calculates several sets of statistics given a sequence of input numbers.

Enter one value on each line.
To exit, press Ctrl-C.
~;

while (1) {
	print ">> ";
	chomp(my $num = <STDIN>);
	$obj->addValue($num);
}
