[Solved] COMP9044 Test 8-Print your Median Argument

$25

File Name: COMP9044_Test_8-Print_your_Median_Argument.zip
File Size: 395.64 KB

SKU: [Solved] COMP9044 Test 8-Print your Median Argument Category: Tag:
5/5 - (1 vote)

Write a Perl program median_number.pl that given positive integers as command line arguments prints the median (middle) value.

Your program can assume is given an odd number of arguments. Your program can assume all its arguments are positive integers.

For example:

$ ./median_number.pl 1 333 42

42

$ ./median_number.pl 3 4 2 1 7 6 5

4

$ ./median_number.pl 15 15 8 11 8

11

$ ./median_number.pl 42 42 244 244 42 42

When you think your program is working you can autotest to run some simple automated tests:

$ 2041 autotest median_number

When you are finished working on this exercise you must submit your work by running give:

$ give cs2041 test08_median_number median_number.pl

Write a Shell program, ls_identical.sh which takes the pathnames of 2 directories as argument.

It should print in alphabetical order the names of all files which occur in both directories and have exactly the same contents.

Files must have the same name in both directories and the same contents for their name to be printed.

Do not print the names of files with same contents but different names in both directories.

For example:

$ ls_identical.1.sh directory1 directory2

You can assume file names do not start with ..

Your answer must be Shell. You can not use other languages such as Perl, Python or C.

No error checking is necessary.

When you think your program is working you can autotest to run some simple automated tests:

$ 2041 autotest shell_ls_identical

When you are finished working on this exercise you must submit your work by running give:

$ give cs2041 test08_shell_ls_identical ls_identical.sh

Write a Perl program, ls_identical.pl which takes the pathnames of 2 directories as argument.

It should print in alphabetical order the names of all files which occur in both directories and have exactly the same contents.

Files must have the same name in both directories and the same contents for their name to be printed.

Do not print the names of files with same contents but different names in both directories.

For example:

$ mkdir directory1 directory2$ echo hello >directory1/same.txt$ echo hello >directory2/same.txt$ echo hello >directory1/different.txt$ echo world >directory2/different.txt$ echo hello >directory1/one.txt$ echo hello >directory2/two.txt $ touch directory1/empty.txt directory2/empty.txt$ ls directory1 different.txt empty.txt one.txt same.txt $ ls directory2 different.txt empty.txt same.txt two.txt$ ls_identical.pl directory1 directory2 empty.txt same.txt

You can assume file names do not start with ..

Your answer must be Perl only. You can not use other languages such as Shell, Python or C.

You may not run external programs, e.g. via system or backquotes. for example, you cant run diff.

You may use any Perl module installed on CSE systems.

No error checking is necessary.

When you think your program is working you can autotest to run some simple automated tests:

$ 2041 autotest perl_ls_identical

When you are finished working on this exercise you must submit your work by running give:

$ give cs2041 test08_perl_ls_identical ls_identical.pl

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] COMP9044 Test 8-Print your Median Argument
$25