THE UNIVERSITY OF TRINIDAD & TOBAGO FINAL ASSESSMENT/EXAMINATIONS DECEMBER 2013 Course Code and Title: Reasoning and Logic for Computing Programme: Diploma in Software Engineering Date and Time: 12 December 2013 (9:00 am 12:00 pm) Duration: 3HRS PLEASE READ ALL INSTRUCTIONS CAREFULLY BEFORE YOU BEGIN THIS EXAMINATION Instructions to Candidates 1. This paper has 5 pages and 9 questions. 2. You are required to answer ALL questions in each Section 3. The use of white off agents is PROHIBITED 4. The paper is graded out of 100 Please return question paper with the Answer script Key Examination Protocol 1. Students please note that academic dishonesty (or cheating) includes but is not limited to plagiarism, collusion, falsification, replication, taking unauthorised notes or devices into an examination, obtaining an unauthorised copy of the examination paper, communicating or trying to communicate with another candidate during the examination, and being a party to impersonation in relation to an examination. 2. The above mentioned and any other actions which compromise the integrity of the academic evaluation process will be fully investigated and addressed in accordance with UTT s academic regulations. 3. Please be reminded that speaking without the Invigilator s permission is NOT allowed. The University of Trinidad & Tobago Page 1 of 5
Section 1 Reasoning and Logic (25 marks) 1. Given that A = TRUE B = TRUE C = FALSE What will the following expressions evaluate to? a.!(a && B) C b. (B C) && (C && A) c. A && (C (!B && B) d. (!A!C) (C &&!B) e. A && (!C && (B!B)) f. A && (B C) (6 marks) 2. For each group of statements, give the final value of y if the initial value of x is 1. a) b) while (x is less than 5) if (x is odd) y = x + y + 12 else if (x is even) endif x= x + 1 endwhile y = y x 3 while (x is less than 10) if (x is less than 6) else endif x = x + 2 endwhile y = x * 3 if (x is greater than or equal to 6) y = y + x + 25 (6 marks) The University of Trinidad & Tobago Page 2 of 5
3. a) List the steps of the Program Development Life Cycle. (2 marks) b) What is the difference between an algorithm and pseudocode? (2 marks) c) What is the difference between decision control statement and (2 marks) a repetition control statement? 4. An insurance company is considering rules to assist in determining whether or not to insure a vehicle. The possible criteria to be used include checks to determine if the vehicle was involved in more than 5 accidents, if the type of vehicle is a taxi or maxi taxi, and if the vehicle is 10 years or older. The possible actions considered include refusing to insure the vehicle, insuring the vehicle with a standard rate plus a discount and / or insuring the vehicle with a special rate with no discounts. Using the above information prepare a decision table to guide insurance agents when insuring vehicles for customers. Justify the rules derived in the decision table. (7 Marks) The University of Trinidad & Tobago Page 3 of 5
Section 2 Algorithms and Pseudocode (20 marks) 5. Write an algorithm to report the contents of a compressed-gas cylinder based on the first letter of the cylinder s color. The algorithm reads a character representing the observed color of the cylinder B or b for brown or G or g for green or O or o for orange or Y or y for yellow, and outputs the type of gas stored in the cylinder. Cylinder colors and associated contents are represented in a table as follows. Cylinder Color brown green orange yellow Type of Gas carbon monoxide oxygen ammonia hydrogen (8 marks) 6. The production supervisor at the Super Oil Company refinery is responsible for monitoring the gasoline supply in a storage tank. The supervisor must be alerted when the supply of gasoline in the tank falls below 10% of the tank s 80,000-barrel storage capacity. Although the supervisor records the contents of the tank in terms of a number of barrels, the pump that is used to fill tanker trucks gives its measure in gallons. In the petroleum industry 1 barrel = 42 U.S. gallons. Write pseudocode logic that will alert the supervisor when the supply of gasoline in the tank falls below 10% of the tank s 80,000-barrel storage capacity. State any assumptions you make. (12 marks) The University of Trinidad & Tobago Page 4 of 5
Section 3 Programming (55 marks) 7. This question is based on the problem presented in question six (6) above. Convert the pseudocode developed in question six (6) above to a C++ program. Be sure to include all syntax elements and comments where necessary. (20 marks) 8. Write a C++ program, with full syntax, to determine the sum and product of the first five (5) terms of the geometric progression 6 18 54... (15 marks) 9. The array gross_sales, shown below, contains sales revenue for the period January June 2013. Write a C++ program, with full syntax, to: a) prompt the user to populate the array with the data as shown below b) compute Value Added Tax (VAT = 15%) and net sales for each period in the array. c) Output the VAT and net sales to the screen Jan Feb Mar Apr May Jun gross_sales 15,275.00 32,300.00 9,550.25 4,234.10 8,980.00 17,657.50 0 1 2 3 4 5 (20 marks) END OF EXAM The University of Trinidad & Tobago Page 5 of 5