programming concepts practice f008

6
  ~  S T  IIII Sri Lanka Institute of Information Technology Foundation Certificate in Information Technology FinalExamination 2011, Term 2 Monday, s September 2011 Programming Conce ts Practice F008) Duration: 3 hours (Time: . 9:00 am - 12:00 noon) In structions to Candidates  _  • This pa er contains FIVE (5) questions on FIVE (5) pages • Answer ALL questions in the WORKBOOK provided. • The entire exam is worth 100 points. The point value of each question is given.

Upload: dimuthu

Post on 07-Oct-2015

217 views

Category:

Documents


0 download

DESCRIPTION

concepts

TRANSCRIPT

  • ..~ ....' ..SLIIT~IIII!~ Sri Lanka Institute ofInformation TechnologyFoundation Certificate in InformationTechnology

    Final Examination2011, Term 2Monday, s" September 2011

    Programming Concepts & Practice (F008)

    Duration: 3 hours(Time: .9:00 am - 12:00 noon)

    Instructions to Candidates-------------- - -----_. ------ - ---

    This paper contains FIVE (5) questions on FIVE (5) pages Answer ALL questions in the WORKBOOK provided. The entire exam is worth 100 points. The point value of each question is

    given.

  • Question 01 (20 marks)

    a) Name the steps in the software development process.b) State the difference between a compiler and an interpreterc) What is Walkthrough? Why is it important?d) Why is documentation an essential part of programming?e) What are the three essential programming constructs?f) List the responsibilities of a Programmer

    [7 marks][3 marks][2 marks][3 marks][3 marks][2 marks]

    Question 02 (20 marks)

    a) Name four language generations with an example for each generation [5 marks]b) Distinguish between compilers and Interpreters [2 marks]c) What are the three types of errors that can occur in a program? Explain each of them

    indicating how the error can be discovered [3 marks]d) Read the following phrases and mark True or False with an X [10 marks]

    No. Phrase True False1 It may be necessary to run a program on a compiler more than

    once.

    2 The Assembler is used to translate Object code into Source code.

    3 When using a compiler, Translation is done on the fly.

    4 Java is a Procedural Language.

    5 When using an IF statement it is not necessary to always write anr:ELSE statement with it.

    6 "WHILE (num> 100 && num

  • Question 03 (15 marks)

    a) Write the output for the following test data when inserted to this Flow Chart

    This System will determine theActivity to do according to theWeather, Day and Time Initialize Weather

    Initialize DayInitialize Time

    Get Day

    Get Time

    FalseTrue

    False

    Display

    "Bowllnz"

    [6 marks]

    False

  • .,

    I. Test Case 1: Weather = "Sunny"Day = "Holiday"Time = "Night"

    II. Test Case 2: Weather = "Sunny"Day = "Work Day"Time = "Morning"

    III. Test Case 3 : Weather = "Rainy"Day = "Work Day"Time = "Night"

    b) Write the output for the following test data when inserted to this PseudocodeBegin Test Data: 7Initialize Count=O, ValueGet ValueWhile Count< = Value Do

    Display Value-CountCount=Count+ 2

    End WhileEnd

    [4 marks]

    c) Write the output for the following test data when inserted to this Structure Chart [5 marks]

    I. Test Case 1 : Number = 0II. Test Case 2 : Number = 2

    3

    Functions List

    1. Get Number

    2. Number=Number*Number

    3. Number=Number-14.Display "Cannot Multiply"5. Display Number

    Conditions List

    1. If Number> 02.For 1 to 4

  • Question 04 (20 marks)

    Design an algorithm using Pseudocode for a System that will greet the user. The user shouldenter the Name, Gender and Marital Status. The System will then greet the user accordingly.Your solution should contain:

    1. Defining diagram (Inputs, Processing, Outputs)2. Pseudocode algorithm

    Ex 1: Name: SamanGender: MaleMarital Status: Married

    Output: "Welcome Mr. Saman"

    . Ex 2: Name: AjithGender: MaleMarital Status: Single

    Output: "Welcome Mr. Ajith"

    Ex 3: Name: MihiriGender: FemaleMarital Status: Single

    Output: "Welcome Miss. Mihiri"

    Ex 4: Name: KumariGender: FemaleMarital Status: Married

    Output: "Welcome Mrs. Kumari"

    Note: the algorithm should be valid for all scenarios as shown aboveHint: When combining a set of variables together use concatenation:

    "Welcome "v Maritalstatus+", "+Name

    4

  • Question 05 (25 marks)

    1. Design an algorithm using Flow Chart for a System that calculates the Salary of anemployee. The user enters the salary amount (per hour), then the user enters the number ofdays worked. The System then gets the number of hours worked for each day and calculatesthe total salary. [15 marks]

    Ex: Salary: 1000Days: 3Day 1: 2hrs = 2000Day 2: l hr = 1000Day 3: 4hrs = 4000

    Total = 7000

    Ex: Salary: 2500Days: 5Day 1: 3hrs = 7500Day 2: 2hrs = 5000Day 3: 4hr = 10000Day 4: Ohrs = 0Day 5: 2hrs = 5000

    Total =27500

    2. Design an algorithm using Structure Chart for the following System: [10 marks]

    Sam and Ella's food store wants you to write a program to take orders from the Internet. Theprogram asks for the Item and its price. For items under $10 the shipping price is &2.00. Foritems $10 or more the shipping price is $3.00. The program then calculates the total amount forprice and shipping

    r- Ex: item = Tuna SaladPrice = 4

    Invoice:

    Tuna Salad = 4.00Shipping = 2.00

    ----.----Total =-6.00 . _

    5