#!/usr/bin/perl 
# Purpose:   Simple calculation, string assignment, <STDIN> input, 

my $pi = 3.141592654;

sub Circumference
{
$C = 2*$pi*$r;
print "\n\tWith Radious $r, Circumference = $C\n\n";
}

sub ValidNumber
{
if ( $input_number =~ /^\d+$/ && $input_number gt 0 )
  {
	$valid_number=$input_number;
	return;
   } else { 	
   	print "You must enter a number ( greater than zero ).\n";
   	print "Your input radious was $input_number, so I am skipping it.\n";
   	print "Sorry.\n";
   	exit 0;
   }
}


print "#############################################################################\n";
print "Assignment 1, Problem 1.  Calculates circumference (C)of a circle w\/ radious 12.5.\n\n";
print '    Circumference of a circle is calucated with C=2*pi*r  
	C   = Circumference
	pi  = 3.141592654
	r   = radious	
';
$r=12.5;
Circumference();

print "#############################################################################\n";
print "Assignment 1, Problem 2.  Prompt for and accept a radious from the person running the program.\n\n";
print "\tType in a radious ( grater than zero ) and press Enter:\t";
$input_number=<STDIN> ;  chop($input_number) ;
ValidNumber ();
$r=$valid_number;
Circumference();

print "#############################################################################\n";
print "Assignment 1, Problem 3.  Prompt for 2 numbers, multiply numbers together and print result.\n\n";
print "\tType the first number (greater than 0) and press enter: ";
$input_number=<STDIN> ;  chop($input_number) ;
ValidNumber ();
$fist_number=$valid_number;

print "\tType the second number (greater than 0) and press enter: ";
$input_number=<STDIN> ;  chop($input_number) ;
ValidNumber ();
$second_number=$valid_number;

$first_times_second=$fist_number*$second_number ;
print "\n\tResult:  $first_times_second *  $second_number = $first_times_second.\n";

print "#############################################################################\n";
print "Assignment 1, Problem 4.  Prompt for a string and a number (n), and print the string n times.\n\n";
print "\tType in a string of characters and then press enter: \t";
$input_string=<STDIN> ;  chop($input_string) ;
print "\tType in a number (greater than 0) and press enter: \t";
$input_number=<STDIN> ;  chop($input_number) ;
ValidNumber ();
$number_of_times=$valid_number;
$new_string= $input_string x $number_of_times;
print "\tResult:  $new_string\n\n";
print "##############################################################################\n";

exit;
