[SOLVED] COMP9044 - Week 07 Weekly Test Questions

30.00 $

Category:

Description

5/5 - (1 vote)

Echo If Consecutive Three Vowels

Write a Perl program three_vowel_echo.pl that prints its command-line argument to standard output, similar to echo command in Shell, except arguments should be printed only if they contain 3 consecutive vowels.

Your program can assume vowels are there are 5 vowel {‘a’, ‘e’, ‘i’, ‘o’, ‘u’} and their upper-case equivalents {‘A’, ‘E’, ‘I’, ‘O’, ‘U’} 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.

$ ./three_vowel_echo.pl Pompeii Rome Aeolian Florence

Pompeii Aeolian

$ ./three_vowel_echo.pl

$ ./three_vowel_echo.pl an anxious bedouin beauty booed an ancient zoologist anxious bedouin beauty booed

$ ./three_vowel_echo.pl abstemiously adenocarcinomatous Hawaiian Eoanthropus abstemiously Hawaiian Eoanthropus

Wh               thi k                           i          ki                                       t                       i      l        t         t d t     t

 

$ cat odd.txt line 0 line 1 line 2 line 3 line 4

$ ./middle_lines.pl odd.txt line 2

$ cat even.txt line 0 line 1 line 2 line 3 line 4 line 5

$ ./middle_lines.pl even.txt line 2 line 3

$ ./middle_lines.pl /dev/null

 

Print the Line(s) from Stdin With the Largest Number

Write a Perl program largest_numbered_line.pl that read lines from standardinput until end-of-input. It should then print the line(s) which contained the largest number.

You can assume numbers do not contain white space, commas or other extra characters.

You can assume numbers are only in decimal format.

You can assume numbers are not in scientific/exponential format.

Lines may contain multiple numbers and they may contain any number of any character between the numbers.

If the largest number occurs on multiple lines you should print all of the lines in the order they occurred.

If no line contains a number, your program should print nothing.

$ ./largest_numbered_line.pl

I spent $ 15.50 for

3.3 kg apples yesterday.

2000 is a leap year.

Ctrl-D                         

2000 is a leap year.

$ ./largest_numbered_line.pl two2 four4 eight8 sixteen16

1 sixteen-and-half 16.5  1

11 12 13

Ctrl-D                         

1 sixteen-and-half 16.5  1

$ ./largest_numbered_line.pl the quick brown f42ox

4 9 42 2 4 1 2 3 4 42.0 no forty two last 42

Ctrl-D                         

the quick brown f42ox

4 9 42 2 4 1 2 3 4 42.0 last 42

$ ./largest_numbered_line.pl a 0.01 b .5 c -0.9

Ctrl-D     b .5

$ ./largest_numbered_line.pl a -.5 b -5 c –90–

Ctrl-D                         

a -.5

$ ./largest_numbered_line.pl I love programming in Perl but I like Python better.

Ctrl-D                         

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.

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