#! Perl -w # hypo.pl -- find the hypotenuse use strict; sub compute { my $opt = shift; if ($opt == 1) { print "\n\tWhat is A? "; chomp(my $a = ); print "\tWhat is B? "; chomp(my $b = ); my $c = sqrt($a**2 + $b**2); print "\tC = $c\n"; } elsif ($opt == 2) { print "\n\tWhat is A? "; chomp(my $a = ); print "\tWhat is C? "; chomp(my $c = ); die "A cannot be greater than or equal to C!" if $a >= $c; my $b = sqrt($c**2 - $a**2); print "\tB = $b\n"; } else { die "User did no enter 1 or two"; }} print "\nC /|\n \\ / |\n / |-B\n", " / |\n/____|\t1: Use A & B to find C\n", " \\\t2: Use A & C to find B\n A\n"; print "\tChoice: "; chomp(my $choice = ); compute($choice);