Chapter 2 and 3 - Tutorial 3
Creating The IPO Table Recall
Phase | Practical Meaning | Typical Keywords (in the problem text) |
---|---|---|
Input | Data accepted from the user — always nouns, never actions. NEVER USE VERB. | enter, read, get |
Process | Operations applied to the inputs — arithmetic, decisions, loops. Each item should begin with a verb. The suggested structure for selection question is: DETERMINE THE + CONSTANT + BASED ON + INPUT VERB + OUTPUT + BASED ON INPUT AND CONSTANT | calculate, compute, determine, if, while, repeat |
Output | The result delivered to the user or another system — again nouns or messages. NEVER USE VERB. | display, print, show |
Creating The Flowchart Recall
Shape | Usage | Tips |
---|---|---|
Capsule | Input and output | Make sure to use VERB to clarify whether you are doing input or output |
Arrow | Program direction | All shapes except diamond can only have one arrow coming out of them; the arrows coming in are limitless |
Rectangle | Process | One process box can be used for one or multiple processes at one time |
Diamond | Selection | Make sure to put TRUE and FALSE on arrow going out of the diamond |
Implementing IPO and Flowchart
For each of the questions below, create an IPO table and its respective flowchart
Scenario 1 - Selling Magazine Question
MyHealth magazine is sold at RM5.00 each if at least 5 units of the magazine are purchased, and it is sold at the price of RM7.00 each otherwise. Calculate the price a customer has to pay after they enter the quantity of the magazines that they purchased.
Scenario 2 - Library Books Question
A library system calculates whether a late fee should be charged to a member returning a book based on the return date. If the book is returned on time, no fee is charged. If it's late, a fee of RM1.00 per the number of overdue days is applied.
Scenario 3 - Electricity Bill Question
A utility company charges RM0.30 per kWh for the first 100 kWh, RM0.50 per kWh for the next 100 kWh (101–200 kWh), and RM0.75 per kWh for any usage above 200 kWh.
Calculate the total bill when the customer enters their total kWh consumed.
Scenario 4 - Income Tax Slab Question
Income tax is applied as:
First RM50,000.00 → 0%
Next RM50,000.00 → 1%
Above RM100,000.00 → 2%
Given an annual income, calculate total tax due.
Scenario 5 - Parking Fee Question
A mall charges parking as follows:
First 2 hours → Free
Next 3 hours (2–5 hours) → RM2.00 per hour
Beyond 5 hours → RM3.00 per hour
Maximum charge per day → RM30.00
Given total hours parked, calculate the parking fee.
Scenario 6 - Baggage Allowance Logic Question
A flight ticket that includes 15 kg of free baggage. Excess baggage is charged RM4.00 per kg beyond that limit. However, if the passenger brings no baggage, they receive a RM10.00 discount on the total ticket price.
Given the weight of baggage and ticket price, calculate the final price.
Scenario 7 - Early Bird Discount Logic Question
If a user registers before the 15th day of the month, they get a 10% discount. Otherwise, they pay full price.
Given the day of registration and base fee, calculate the final fee.
Scenario 8 - Final Score Question
Final score is calculated as:
Midterm 30%
Assignment 20%
Final exam 50%
But if any of the three components is below 30, the final score is automatically 0.
Given all three marks, calculate final result.