Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

~ Perl Assignment 01 ~ Objectives To get practice in using the Perl language by using common programming concepts: Scalars, arithmetic, user input, if-statements, loops

~ Perl Assignment 01 ~

  • Objectives
    • To get practice in using the Perl language by using common programming concepts:
      • Scalars, arithmetic, user input, if-statements, loops
    • Create 2 Perl scripts given the following specifications
  • Perl Program 01A
    1. Create a perl script named LastnameFirstname01A.pl.
    2. Include strict and warnings at the top of your program.
    3. This script will compute the circumference of a circle given a radius.
      • The formula for computing circumference is 2r, that is 2 * pi * r.
      • You may use the value 3.14 for the value of pi.
    4. Store the value of pi in a scalar variable.
    5. Output a message stating to the user that this script calculates circumference.
    6. Ask the user to enter in the radius.
    7. Retrieve the radius from standard input and store it in a scalar variable.
    8. Calculate the circumference.
      • If the user enters a number less than zero, output 0 instead of a negative number.
    9. Output the result of the calculation.
    10. Ensure all output is properly labeled.
    11. It is okay when your program crashes if the user enters letters or symbols instead of a number, we will deal with those later.
    12. Ensure that your code is sufficiently styled and documented.
      • Styled meaning code is indented when applicable, variables are named properly, etc.
      • Documentation includes a program description at the top and in-line comments throughout the script.
      • See posted examples in the Lecture Material page.
  • Perl Program 01B
    1. Create a perl script named LastnameFirstname01B.pl.
    2. Include strict and warnings at the top of your program.
    3. Note: This script has no user input.
    4. Create a loop to print the numbers from 1 to 100, each number on its own line.
      • You do not need an array to accomplish this, simply create a loop that counts from 1 to 100 and print the loop increment variable.
    5. Modify the loop so that numbers with certain characteristics print a word instead:
      • For numbers divisible only by 3, print "Spam" instead of the number.
      • For numbers divisible only by 7, print "Musubi" instead of the number.
      • For numbers divisible by 3 and 7, print "SpamMusubi" instead of the number.
      • All other numbers, just print them out.
      • Use the modulo operator % to determine if a number is divisible by another number.
        • For example, to test if a number is divisible by 3, the condition would be:
        • if ($i % 3 == 0), where $i represents the number you want to test which can be replaced by a value or another scalar variable that contains the number.
    6. Ensure that your code is sufficiently styled and documented.
      • Styled meaning code is indented when applicable, variables are named properly, etc.
      • Documentation includes a program description at the top and in-line comments throughout the script.
      • See posted examples in the Lecture Material page.
  • Submission Guidelines
    • Submit both your perl scripts to the Digital Dropbox.
      • Be sure to check your hawaii.edu e-mail for confirmation of your submission.
    • Due Date: Tuesday, Jan. 25 by 11:55pm
  • Perl Program 01B Output
> perl MeyerEdward01B.p1 1 2 Spam 4 5 Spam Musubi 8 Spam 10 11 Spam 13 Musubi Spam 16 17 Spam 19 20 SpamMusubi 22 23 Spam 25 26 Spam Musubi 29 Spam 31 32 Spam 34 Musubi Spam 37 38 Spam 40 41 SpamMusubi 43 44 Spam 46 47 Spam Musubi 50 Spam 52 53 Spam 55 Musubi Spam 58 59 Spam 61 62 SpamMusubi 64 65 Spam 67 68 Spam Musubi 71 Spam 73 74 Spam 76 Musubi Spam 79 80 Spam 82 83 SpamMusubi 85 86 Spam 88 89 Spam Musubi 92 Spam 94 95 Spam 97 Musubi Spam 100

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

8th Edition

013460153X, 978-0134601533

More Books

Students also viewed these Databases questions

Question

What is market segmentation?

Answered: 1 week ago

Question

LO6 List the components of job descriptions.

Answered: 1 week ago

Question

LO3 Define job design and identify common approaches to job design.

Answered: 1 week ago