1 Deakin College SIT105 Critical Thinking and Problem Solving for IT Assignment 2 Trimester 1 2016 This assignment is to be completed individually. It is worth 15% of overall marks. It is due on or before 8.30 am Monday May 16 (Week 11). Objectives: There are several goals for the assignment: To demonstrate your understanding of some of the concepts behind programming; To demonstrate a methodical approach to solving problems; and To design and develop algorithms using sequence, selection and iterative constructs and modularisation. Tasks: Carefully read all of the questions and provide solutions to all four questions. Word process your solution and convert the whole document to .pdf Submit your assignment in the assignment submission tool available in Moodle (Week 11). Late submissions will be penalised. Note: The assignment is marked out of 30 marks but is worth 15 marks i.e. 15% Your assignment will be assessed on how well your solutions have addressed the problem and met the requirements, and on the overall “correctness” of your solutions. Use of appropriate constructs; appropriate messages/error messages; suitable formatting of output; and use of appropriate modularisation techniques are further assessment criteria. 1. Draw a defining diagram (IPO Chart) for the following problem statement (5 marks). A program that prompts for and obtains the hourly temperatures for a whole day (24 hours). These temperatures should be between -5 and +45. The mean, minimum, maximum temperature for the day should be displayed. Appropriate error messages should be included. 2. Write a desk check for the following algorithm (5 marks). 1 SUMPROGRAM 2 total = 0 3 count = 0 4 GET number 5 DOWHILE number >=0 6 total = total + number 7 count = count + 1 8 GET number 9 ENDDO 10 IF total >0 11 mean = total/count 12 DISPLAY “The total is “total 13 DISPLAY “The average is “mean 14 ENDIF 15 END 2 3. Develop an algorithm for the following problem statement. Your solution should be pseudocode with appropriate comments (5 marks). A program that will prompt the user for an annual salary and then calculate the amount of tax that should be paid. The tax rate that applies is shown in the table below. Annual Salary Tax 0 – $18,200 Nil $18,201 – $37,000 19c for each $1 over $18,200 $37,001 – $80,000 $3,572 plus 32.5c for each $1 over $37,000 $80,001 – $180,000 $17,547 plus 37c for each $1 over $80,000 $180,001 and over $54,547 plus 45c for each $1 over $180,000 If an invalid annual salary has been entered (negative or zero), then the user should be asked to re-enter the annual salary again. The annual salary and the amount of tax should be displayed to the screen with appropriate messages. 4. Develop an algorithm for the following problem statement. Your solution should be a hierarchy chart, and pseudocode. You should use modularisation in your solution and provide appropriate error messages and comments (15 marks). Write an algorithm that will process a file for a fruit shop. The records in the file have a unique batch number, a fruit name, the weight (in kilograms) of fruit left in the batch, arrival date of the batch, and cost price of the fruit (per kilogram). Assume that only three types of fruit are sold: apple, pear and banana. For example, the first records of the file might contain the following data. Batch Number Fruit Name Weight(kg) Arrival Date Cost Price 1234 Apple 102 22-Apr-2016 1.50 1345 Banana 212 02-May-2016 1.80 1789 Pear 97 28-Apr-2016 2.40 1801 Apple 88 03-May-2016 1.20 1980 Banana 180 22-Apr-2016 1.95 Your algorithm is to calculate and display the value of sales (in $) if all fruit is sold. Fruit is sold to the public at a percentage profit margin such as 60% or 70% for all fruit (Note: The selling price of fruit is cost price + cost price * percentage profit margin). Your algorithm should prompt the user to enter the percentage profit margin immediately the algorithm starts. However batches of fruit before a particular date, such as 01 May 2016, cannot be sold to the public because the fruit is too old. Your algorithm should prompt the user to enter such a date immediately after obtaining the percentage profit margin. The fruit shop has a contract with a pig farmer who will buy all batches of old apples and old pears (not bananas) at 15 cents per kilogram. Once all of the fruit records are processed, the algorithm should display the value ($) of fruit that can be sold to the public and also the number of kilograms and value ($) of fruit that can be sold to the pig farmer, with appropriate messages. A total value ($) should also be shown.