Need help with some PERL scripting using LinuxUNIX please Wr

Need help with some PERL scripting using Linux/UNIX please:

Write a script called activity6.2-7.pl that asks the user to guess a number set by the program, then display an appropriate message. Example output below.

Purpose: Guessing number

bash-3.2$ perl activity6.2-7.pl
Enter a number between 0 and 9: _-4__

Warning: You entered a negative number! Your number is slightly lower...


bash-3.2$ perl activity6.2-7.pl
Enter a number between 0 and 9: _5__
Your number is slightly lower...


bash-3.2$ perl activity6.2-7.pl
Enter a number between 0 and 9: _7__ Good job! You guessed the correct number...

bash-3.2$ perl activity6.2-7.pl
Enter a number between 0 and 9: _11__ Your number is slightly higher...

Solution

#!/usr/local/bin/perl

print \"Enter a number between 0 and 9:\ \";
$number = <>;

if( $number < 0 )
{
print \"Warning: You have entered a negative number!Your number is slightly lower...\";
}
if( $number > 0 && $number < 7 )
{
print \"Your number is slightly lower...\";
}
if( $number == 7 )
{
print \"Good job!You guessed the correct number...\";
}
if( $number > 7 )
{
print \"Your number is slightly higher...\"
}

Need help with some PERL scripting using Linux/UNIX please: Write a script called activity6.2-7.pl that asks the user to guess a number set by the program, then

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site