Write a program in Perl called random.pl. The program chooses a random number from 1 to 50. The program should generate the random number and save to a variable. The program will then ask the user to guess the number. Keep asking the user to guess the number until they either get it right or quit playing. If the input is quit or exit it should end the program; otherwise keep asking for a number. Tell the user "lower" if the saved number is lower than the guessed number, or say "higher" if the saved number is higher than the guessed number. Count how many guesses it takes for the user to guess the saved number. Display the count of guesses and a message of " Congratulations" after guessing correctly.

Requirements:

  • The input allows only 1 to 50, quit or exit.
  • The program exits properly on a quit or exit.
  • The logic functions correctly.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.