Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

DELIVERABLE: Please insert your codes after the corresponding questions in this document and submit either a Word or a PDF document ACTIVITIES (4pts * 10

DELIVERABLE:

Please insert your codes after the corresponding questions in this document and submit either a Word or a PDF document

ACTIVITIES (4pts * 10 = 40 pts)

Write a perl script called msg.pl to accomplish the following tasks:

Assign your first name to variable fname

Assign your last name to variable lname

Assign the value 30 to variable hours, and 15 to variable pay_rate, and compute the gross_pay as hours* pay_rate

Display the message:

Hello World!

My name is ,

I earned $ this week

This is my first PERL script

Be sure to include the header information, which must be sandwiched between two lines of 72 pound signs (#) each

Write substring.pl to perform the task below:

Consider the variable

$path = /usr/bin/perl,

Replace the characters after the last / with tclsh

Use substr function to modify $path to be /usr/local/bin/tclsh

Note: To insert a string with substr, assign that string to the appropriate formula.

substr(str1, offset, 0) = str2 will insert str2 into str1 starting at index offset

Write a script called interactive.pl that prompts the user 4 times: the first time for the students name, and the next 3 times for the scores in quiz1, quiz2, and quiz3 respectively. The script will then compute the average.

Set the number of quizzes to 3 using the constant pragma.

The output of your script should look like below:

Purpose: Computing Quizzes Average

Name Quiz1 Quiz2 Quiz3 Average

Jon Doe 12 14 15 13.66

Dont forget to include the header information

Consider the grade roster below:

pchen72 50 71 55 93 115

jmaszk 45 76 49 88 102

bvbui 59 78 53 96 145

mtcrowle 33 65 39 82 100

mrchave3 54 77 56 98 158

Write the script array.pl that reads into an array called grades the data above, entered from the keyboard, then displays:

The whole array, as shown above

The number of students

The last index of the array

The third record entered

Consider the grade roster below:

pchen72 50 71 55 93 115

jmaszk 45 76 49 88 102

bvbui 59 78 53 96 145

mtcrowle 33 65 39 82 100

mrchave3 54 77 56 98 158

Write the script hash.pl that creates a hash for the grades above (usernames are the keys); then print:

The list of students (identified by their usernames)

For any student whose username is provided as command line argument, his grades

Write a script called splitjoin.pl that prompts the user once for the name, quiz1, quiz2, and quiz3 score separated by commas. The script will then compute the average.

The output of your script should look like below. The display of the last two lines must be the outputs from two join() functions.

Purpose: Computing Quizzes Average

Name Quiz1 Quiz2 Quiz3 Average

Jon Doe 12 14 15 13.66

Dont forget to include the header information

Write a script called ifstatement.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 ifstatement.pl

Enter a number between 0 and 9: _-4__

Warning: You entered a negative number!

Your number is slightly lower

bash-3.2$ perl ifstatement.pl

Enter a number between 0 and 9: _5__

Your number is slightly lower

bash-3.2$ perl ifstatement.pl

Enter a number between 0 and 9: _7__

Good job! You guessed the correct number

bash-3.2$ perl ifstatement.pl

Enter a number between 0 and 9: _11__

Your number is slightly higher

Consider the hash you created in the hash.pl activity.

Write a perl script called loop.pl that compute the final percentage score for each student, as well as the class average

The max score is 450 and must be set as constant.

The output should be:

Total number of records: 5

Final score for pchen72 = 85.33%

Final score for jmaszk = 80%

Class Average = 86.1%

The header line should show: Final Score computation

For this activity, use the while-loop with the diamond operator, the split function on a space character, and the $_ variable. Assuming the file score is specified as argument.

$ cat score

pchen72 50 71 55 93 115

jmaszk 45 76 49 88 102

bvbui 59 78 53 96 145

mtcrowle 33 65 39 82 100

mrchave3 54 77 56 98 158

Write a perl script called whileloop.pl that compute the final percentage score for each student, as well as the class average

The max score is 450 and must be set as constant.

The output should be (round the score to nearest integer):

Total number of records: 5

Final score for pchen72 = 85%

Final score for jmaszk = 80%

Class Average = 86%

The header line should show: Final Score computation

Write a perl script called subroutine.pl that assigns values to two variables, then calls the subroutine addplusone() with the two variables as arguments and assigns the value returned by the subroutine to a variable.

The subroutine addplusone() adds 2 to the sum of the two arguments and returns the result.

For example, when the values 3 and 7 are assigned in the main program, the below sample run ensues:

$ perl subroutine.pl

Answer is 12

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

Step: 3

blur-text-image

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

PostgreSQL 10 High Performance Expert Techniques For Query Optimization High Availability And Efficient Database Maintenance

Authors: Ibrar Ahmed ,Gregory Smith ,Enrico Pirozzi

3rd Edition

1788474481, 978-1788474481

More Books

Students also viewed these Databases questions