Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help with some PERL scripting using Linux/UNIX please: Write a script calle

ID: 3798654 • Letter: N

Question

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...

Explanation / Answer

#!/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..."
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote