perl take home final exam

4
Linux IV – Perl Programming Take Home - Final Examination LINUX IV – PERL PROGRAMMING Directly print your code to short bond paper using notepad or DOS type command. Do not, copy paste it to other application. This will have an effect to the code. Staple the bond paper with this questionnaire, being the first page, before submitting it. Write your printed name at the upper left side of every bond paper you’ve used and affix your signature on top of the printed name. Put it in a short brown envelope and write your name, course, and subject in front of the envelope. Submit your exam papers personally on or before 10:00 P.M. of March 14, 2011, Monday. Time will be based on the wall clock located at the stairway in ITCC. Non-compliance with the above instructions would invalidate your exam and thus will require you to take the special exam Good luck and thank you for a wonderful semester! Create a PERL script that will perform the following: Name: ___________________________________ LINUX IV – PERL PROGRAMMING TEST I – PERL PROGRAMMING CELLPHONE TRANSACTION Transaction Menu 1. View account Balance 2. Share-A-Load 3. Load 4. Text 5. Call 6. Exit Choice: Conditions: The following are the conditions for call and text options: - the user could only text if he/she has at lest 1 peso load o if the account has less than 1 peso, then the message “Message Sending Failed!” will be displayed o 1 peso per text - The user can only call if he or she has at least 8 pesos in his/her account - The user can share-a-load if he/she has enough balance in his/her account Sample Output View Account Balance Your account balance as of today is 12.50 Share-A-Load Enter Mobile Number: 09228545127

Upload: binsent-ribera

Post on 25-May-2015

1.309 views

Category:

Education


0 download

DESCRIPTION

Take Home Final Exam of 4CS and 4IT

TRANSCRIPT

Page 1: Perl take home final exam

Linux IV – Perl ProgrammingTake Home - Final ExaminationLINUX IV – PERL PROGRAMMING

Directly print your code to short bond paper using notepad or DOS type command. Do not, copy paste it to other application. This will have an effect to the code.

Staple the bond paper with this questionnaire, being the first page, before submitting it. Write your printed name at the upper left side of every bond paper you’ve used and affix your signature on top of

the printed name. Put it in a short brown envelope and write your name, course, and subject in front of the envelope. Submit your exam papers personally on or before 10:00 P.M. of March 14, 2011, Monday. Time will be based on

the wall clock located at the stairway in ITCC.

Non-compliance with the above instructions would invalidate your exam and thus will require you to take the special exam

Good luck and thank you for a wonderful semester!

Create a PERL script that will perform the following:

Name: ___________________________________ LINUX IV – PERL PROGRAMMING

TEST I – PERL PROGRAMMING

CELLPHONE TRANSACTION

Transaction Menu1. View account Balance2. Share-A-Load3. Load4. Text5. Call6. ExitChoice:

Conditions:The following are the conditions for call and text options:

- the user could only text if he/she has at lest 1 peso loado if the account has less than 1 peso, then the message “Message Sending Failed!” will be displayedo 1 peso per text

- The user can only call if he or she has at least 8 pesos in his/her account- The user can share-a-load if he/she has enough balance in his/her account

Sample Output

View Account BalanceYour account balance as of today is 12.50

Share-A-LoadEnter Mobile Number: 09228545127Amount: 10

Confirmation:Your Share-A-Load has successfully sent!1 peso service fee for the share-a-load transaction

Your current balance as of now is 1.50

TextEnter Mobile Number: 09228545127Message: Congratulations Pare!

Page 2: Perl take home final exam

Confirmation:Message has been successfully sent

CallEnter Mobile Number: 09228545127

Confirmation:Your do not have enough balance to make this call! Please reload now.

LoadEnter Mobile Number: 09228545127Amount: 100

Confirmation:100 peso has been loaded to your accountYour current balance is 101.50

Page 3: Perl take home final exam

LINUX IV – WRITTEN Exam should be accomplished using your own hand writing using ballpen of blue ink only. Write your answers in a short bond paper (8x11); do not write at the back of the bond paper. Staple the bond

paper with this questionnaire, being the first page, before submitting it. Write your printed name at the upper left side of every bond paper you’ve used and affix your signature on top of

the printed name. Put it in a short brown envelope and write your name, course, and subject in front of the envelope. Submit your exam papers personally on or before 10:00 P.M. of March 14, 2011, Monday. Time will be based on

the wall clock located at the stairway in ITCC.

Non-compliance with the above instructions would invalidate your exam and thus will require you to take the special exam

Good luck and thank you for a wonderful semester!

Name: ___________________________________ LINUX IV – PERL PROGRAMMING

TEST II – WRITTEN

Write a program that reads a line of input and prints out the following:

11 if the line consists of a non-zero integer 00 if the line consists of 0 or a string 

Suppose the value of $num is 2010. What string is assigned to $text in each of the following cases?a    $text = "This string contains $num.";b    $text = "\\$num is my favorite number.";c    $text = 'Assign \$num to this string.';

What is the value of the following expressions?a.   17 * 2 ** 3 / 9 % 2 << 2b.   0 && (171567 * 98275 / 1174.5 ** 4)c.   1171 ^ 904d.   "abc" . "de" x 2

Assume the following assignments have been performed:@list = (1, 2, 3);$scalar1 = "hello";$scalar2 = "there";

What is assigned to the array variable @newlist in each of the following cases?a.   @newlist = @list;b.   @newlist = reverse(@list[1,2]);c.   @newlist = ($scalar1, @list[1,1]); d.   ($dummy, @newlist) = @list;e.   @newlist[2,1,3] = @list[1,2,1];f.   @newlist = <STDIN>;

Assume that the following assignments have been performed: @list1 = (1, 2, 3, 4);@list2 = ("one", "two", "three");

Page 4: Perl take home final exam

What is the value of $result in each of the following cases?($dummy, $result) = @list1;$result = @list1;($result) = @list2;($result) = @list1[1..2];$result = $list2[$list1[$list1[0]]];$result = $list2[3];