#!/usr/bin/perl
use strict;
use warnings;
use Math::Trig;
use Math::Complex;
print"+-----------------------------+\n";
print"|Welcome To the perl Calulator|\n";
print"+-----------------------------+\n";
my $cont="y";
do{
#Asks for a operator from the list offered
print"+----------------------------------------------+\n";
print"Please choose a operator from the following list\n";
print"+----------------------------------------------+";
print"\n1)Addition\n2)Subtration\n3)Multiplication\n4)Division\n5)Sine\n6)Cosine\n7)Tangent\n8)Exponential\n9)Natrual Log\n10)Square Root\n11)Power of 2\n";
print"+----------------------------------------------+\n";
my $choice = <STDIN>;
chomp($choice);
#///////////////////////////////////Adittion////////////////////////////
if($choice == 1){
    #Grabs the first number
    print"Please enter the first Number:";
    my $num1 = <STDIN>;
    chomp($num1);
    #Grabs the second number
    print"Please enter the second Number:";
    my $num2 = <STDIN>;
    chomp($num2);
    print"Your Choice is Addition"; 
    my $ans = eval "$num1 + $num2";
    print "\nResult: $num1 + $num2 = $ans\n";

#//////////////////////////////////Subtraction///////////////////////////
}elsif($choice ==2){
    #Grabs the first number
    print"Please enter the first Number:";
    my $num1 = <STDIN>;
    chomp($num1);
    #Grabs the second number
    print"Please enter the second Number:";
    my $num2 = <STDIN>;
    chomp($num2);
    print"Your Choice is Subtraction"; 
    my $ans = eval "$num1 - $num2";
    print "\nResult: $num1 - $num2 = $ans\n";

#/////////////////////////////////Multiplication/////////////////////////
}elsif($choice==3){
    #Grabs the first number
    print"Please enter the first Number:";
    my $num1 = <STDIN>;
    chomp($num1);
    #Grabs the second number
    print"Please enter the second Number:";
    my $num2 = <STDIN>;
    chomp($num2);
    print"Your Choice is Multiplication"; 
    my $ans = eval "$num1 * $num2";
    print "\nResult: $num1 * $num2 = $ans\n";

#////////////////////////////////Division/////////////////////////////////
}elsif($choice==4){
    #Grabs the first number
    print"Please enter the first Number:";
    my $num1 = <STDIN>;
    chomp($num1);
    #Grabs the second number
    print"Please enter the second Number:";
    my $num2 = <STDIN>;
    chomp($num2);
    if($num2==0){
        print("error\n");
       }else{
    print"Your Choice is Division"; 
    my $ans = eval "$num1 / $num2";
    print "\nResult: $num1 / $num2 = $ans\n";
}

#///////////////////////////////Sine///////////////////////////////////////
}elsif($choice==5){
    #Grabs the first number
    print"Please enter a Degree:";
    my $num1 = <STDIN>;
    chomp($num1);
    print"Your Choice is Sine"; 
    my $rad = deg2rad($num1);
    my $ans = sin($rad);
    print "\nResult: The Sine value of $num1 = $ans\n";

#////////////////////////////////Cosine////////////////////////////////////
}elsif($choice==6){
    #Grabs the first number
    print"Please enter a Degree:";
    my $num1 = <STDIN>;
    chomp($num1);
    print"Your Choice is Cosine"; 
    my $rad = deg2rad($num1);
    my $ans = cos($rad);
    print "\nResult: The Cosine value of $num1 = $ans\n";
 
#//////////////////////////////Tan/////////////////////////////////////////
}elsif($choice==7){
    #Grabs the first number
    print"Please enter a Degree:";
    my $num1 = <STDIN>;
    chomp($num1);
    print"Your Choice is Tangent"; 
    my $rad = deg2rad($num1);
    my $ans = tan($rad);
    print "\nResult: The tan value of $num1 = $ans\n";

#//////////////////////////////////Exponential////////////////////////////
}elsif($choice==8){
    #Grabs the first number
    print"Please enter the first Number:";
    my $num1 = <STDIN>;
    chomp($num1);
    print"Your Choice is Exponential"; 
    my $ans = exp($num1);
    print "\nResult: The Exponential of $num1= $ans\n";

#/////////////////////////////////Natrual Log/////////////////////////////
}elsif($choice==9){
    #Grabs the first number
    print"Please enter a Number:";
    my $num1 = <STDIN>;
    chomp($num1);
    #Grabs the second number
   print"Your Choice is Natrual Log"; 
   my $ans = log($num1) / log(10);
   print "\nResult: The Natrual Log of $num1= $ans\n";

#///////////////////////////////Square Root////////////////////////////////
}elsif($choice==10){
    #Grabs the first number
    print"Please enter a Number:";
    my $num1 = <STDIN>;
    chomp($num1);
   print"Your Choice is Square root"; 
   my $ans = sqrt($num1);
   print "\nResult: The square root of $num1 is $ans\n";

#/////////////////////////////Power of 2////////////////////////////////////
}elsif($choice==11){
    #Grabs the first number
    print"please enter a number:";
    my $num1 = <stdin>;
    chomp($num1);
    print"Your Choice is Power of 2"; 
    my $ans = eval "$num1 * $num1";
    print "\nResult: $num1^2 = $ans\n";

}else{
    print"Invalid choice Please try again!";
}
    print"Would you like to continue y/n:";
    my $cont = <stdin>;
    chomp($cont);

}while($cont eq "y")
