spl prelim lab 2011 2012

2
Colegio de San Juan de Letran-Calamba School of Computer Studies and Technology PRELIMINARY EXAMINATION STRUCTURE OF PROGRAMMING LANGUAGES - LABORATORY Name: _______________________________ Date: ____________________ Yr & Section: ___________________________ Prepared by: VSRivera Using Perl, create a program that will accomplish the following: M A I N M E N U 1. Multiplication 2. Division 3. Exit Choice: Multiplication – the user should be able to input 2 numbers, the multiplicand and the multiplier. It should output the product of the 2 numbers using repeated addition. Sample Output: Insert Multiplicand: 5 Insert Multiplier: 3 Product: 15 The multiplicand is added to itself multiplier times, that is, if you are going to add 5 to itself 3 times the sum is the same as the product of 5 multiplied to 3. 5 + 5 + 5 = 15 Division - the user should be able to input 2 numbers, the dividend and the divisor. It should output the quotient of the 2 numbers using repeated subtraction. Sample Output: Insert Dividend: 15 Insert Divisor: 3 Product: 15 The divisor is subtracted from the dividend while the dividend is greater than or equal to the divisor, that is, if you are going to subtract 3 times from 15 while the value is greater than 3, then the number of times 3 will be able to subtract from 15 is the same as the quotient of 15 divided by 3. 15 – 3 = 12 – 3 = 9 – 3 = 6 – 3 = 3 – 3 = 0 Count the number of times the value 3 was able to subtract from 15 while the difference is greater than or equal to 3. Give an appropriate error message if the value of the divisor is greater than the dividend. Output the remainder if the dividend is not exactly divisible by the divisor. 1 Structure of Programming Languages

Upload: binsent-ribera

Post on 25-May-2015

244 views

Category:

Business


3 download

DESCRIPTION

SPL-Perl Take Home Prelim Laboratory Exam

TRANSCRIPT

Page 1: Spl prelim lab 2011 2012

Colegio de San Juan de Letran-CalambaSchool of Computer Studies and Technology

PRELIMINARY EXAMINATIONSTRUCTURE OF PROGRAMMING LANGUAGES - LABORATORY

Name: _______________________________ Date: ____________________Yr & Section: ___________________________ Prepared by: VSRivera

Using Perl, create a program that will accomplish the following:

M A I N M E N U1. Multiplication2. Division3. ExitChoice:

Multiplication – the user should be able to input 2 numbers, the multiplicand and the multiplier. It should output the product of the 2 numbers using repeated addition.Sample Output:

Insert Multiplicand: 5Insert Multiplier: 3Product: 15The multiplicand is added to itself multiplier times, that is, if you are going to add 5 to itself 3 times the sum is the same as the product

of 5 multiplied to 3.5 + 5 + 5 = 15

Division - the user should be able to input 2 numbers, the dividend and the divisor. It should output the quotient of the 2 numbers using repeated subtraction.Sample Output:

Insert Dividend: 15Insert Divisor: 3Product: 15The divisor is subtracted from the dividend while the dividend is greater than or equal to the divisor, that is, if you are going to subtract

3 times from 15 while the value is greater than 3, then the number of times 3 will be able to subtract from 15 is the same as the quotient of 15 divided by 3.

15 – 3 = 12 – 3 = 9 – 3 = 6 – 3 = 3 – 3 = 0Count the number of times the value 3 was able to subtract from 15 while the difference is greater than or equal to 3.

Give an appropriate error message if the value of the divisor is greater than the dividend.Output the remainder if the dividend is not exactly divisible by the divisor.

Exit – terminates the program.

General instruction: Print this exam paper, do not photocopy. Print your program on a short bond paper (8.5” x 11”). Staple the bond paper with this exam paper 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. Write your complete name at the back of the envelope. Submit the envelope personally on or before 12:00 P.M. of July 27, 2011, Wednesday. Time will be based on the wall clock located at

the stairway in ITCC. Again, on or before 12:00 P.M. of July 27, 2011. If you think you cannot submit it on time, submit it before the date or the time of submission.

Softcopy of the program will be collected during our lecture class on July 27, 2011, Wdnesday. Non-compliance with the instruction will mean non-submission, thus, will require you to take a special exam.

1 Structure of Programming Languages