For the following questions, work through steps 1 and 2 of the Steps in Program Development discussed in the lecture. The steps are:
Step 1: Understand the Problem
Step 1a: Read the problem carefully
Step 1b: Check your understanding of the problem
Step 2: Specify a High Level Solution (Defining Diagram)
Step 2a: Determine the outputs
Step 2b: Determine the processing (actions)
Step 2c: Determine the inputs
Step 2d: Develop a Defining Diagram
A draftsperson requires a program to calculate the area of rectangular rooms. The user is to input the length and width of the room, the program is to then calculate the area of the room and the length of the perimeter, and then display the area and perimeter length. The area of a rectangle is its length multiplied by its width. The length of the perimeter of a rectangle is twice the length plus twice the width.
Run Length (m) ? 10 Width (m) ? 5 Area = 50.0 Perimeter = 30.0 Run Length (m) ? 2.5 Width (m) ? 4.0 Area = 10.0 Perimeter = 13.0
A shop owner requires a program to calculate the amount of change to be given to a customer. The price of the item sold and the amount of cash tendered by the customer is to be input and the amount of change is to be calculated and displayed.
Run Price ($) ? 8.95 Cash ($) ? 10.00 Change = $1.05
Run Price ($) ? 20.00 Cash ($) ? 20.00 Change = $0.00
A subject has an assignment and an exam. Both the assignment and exam are marked out of 100. The assignment contributes 40% towards the assessment of the subject and the exam 60%. A program is required that allows the user to input and assignment mark (out of 100) and an exam mark (out of 100) and display an overall mark in the proportions specified.
Run Assignment mark (0 to 100) ? 70 Exam mark (0 to 100) ? 60 Final mark = 64%
Run Assignment mark (0 to 100) ? 80 Exam mark (0 to 100) ? 90 Final mark = 86%
This problem is a little more difficult. The inputs and processing aren't as obvious in this problem. Determine what is implied by the problem description (e.g. where does the amount due come from?) as well as what is explicitly stated.
The Water Board gives a discount of 5% to customers that pay their rates bill early, otherwise the normal rate applies. The program is to display the discount (if applicable) and the amount due.
How is this problem different to problems that we have done so far?
Run Amount Due ($) ? 200.00 Early payment (Y=Yes, N=No) ? Y Discount = $10.00 Amount Payable = $190.00
Run Amount Due ($) ? 100.00 Early payment (Y=Yes, N=No) ? N Amount Payable = $100.00
Written by Tim Whitfort.