1. Engineering
  2. Computer Science
  3. write a perl program that allows the user to input...

Question: write a perl program that allows the user to input...

Question details

Write a Perl program that allows the user to input a 5-digit nonnegative integer number between 10000 and 99999, separates that number into its individual digits and then prints the digits to the screen separated from one another by three spaces each.

If the number entered is not within the range of 10000 and 99999 (inclusive), output an error message that starts with a label of ERROR.

See sample output for examples.

We currently can’t test input for being numeric or non-numeric, so assume that all input will be numeric.

Write a Perl program, thinking about the solution in terms of Perl's available functions instead of a solution

you might come up with in C, C++ or Java.

Remember to have #!/usr/bin/env perl as your shebang line.

Remember to use use Modern::Perl; in your program.

Try to follow the Perl Best Practices that we’ve discussed in class so far

You should only use material presented so far this semester in class, through lecture set of slides #3.

This includes the smart-match operator, relational operators, if conditional statements, the given statement and

Boolean logical operators.

Your error message must start with the label ERROR.

Do not use loops, arrays or the split or substr functions for this assignment.

Make sure to use the use Modern::Perl; statement in your program.

Examples:

Enter a five-digit number: 68182

6   8   1   8   2

Enter a five-digit number: 1234

ERROR: Your number must be in the range 10000 and 99999.

Enter a five-digit number: 01234

ERROR: Your number must be in the range 10000 and 99999.

Enter a five-digit number: 991233  

ERROR: Your number must be in the range 10000 and 99999.

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution