|
| 1 | +--- |
| 2 | +title: Chapter 2 - Tutorial 3 |
| 3 | +outline : deep |
| 4 | +--- |
| 5 | + |
| 6 | +# Chapter 2 and 3 - Tutorial 3 |
| 7 | + |
| 8 | +## Creating The IPO Table <Badge type="warning" text="Recall" /> |
| 9 | + |
| 10 | +| Phase | Practical Meaning | Typical Keywords (in the problem text) | |
| 11 | +|------------|------------------|-----------------------------------------| |
| 12 | +| **Input** | Data accepted from the user — always *nouns*, never actions. **NEVER USE VERB.** | enter, read, get | |
| 13 | +| **Process**| Operations applied to the inputs — arithmetic, decisions, loops. Each item should begin with a **verb**.<br><br> The suggested structure for **selection** question is: <br><br> DETERMINE THE + CONSTANT + BASED ON + INPUT<br><br> VERB + OUTPUT + BASED ON INPUT AND CONSTANT | calculate, compute, determine, if, while, repeat | |
| 14 | +| **Output** | The result delivered to the user or another system — again *nouns* or messages. **NEVER USE VERB.** | display, print, show | |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | +## Creating The Flowchart <Badge type="warning" text="Recall" /> |
| 19 | + |
| 20 | +| Shape | Usage | Tips | |
| 21 | +|------------|----------------------|----------------------------------------------------------------------------| |
| 22 | +| Capsule | Input and output | Make sure to use **VERB** to clarify whether you are doing input or output | |
| 23 | +| Arrow | Program direction | All shape except diamond can only have one arrow coming out of them, the arrow coming in is limitless | |
| 24 | +| Rectangle | Process | One process box can be used for one or multiple process at one time | |
| 25 | +| Diamond | Selection | Make sure to put **TRUE** and **FALSE** on arrow going out of the diamond | |
| 26 | + |
| 27 | + |
| 28 | +## Implementing IPO and Flowchart |
| 29 | + |
| 30 | +For each of the questions below, create an IPO table and its respective flowchart |
| 31 | + |
| 32 | +### Scenario 1 - Selling Magazine <Badge type="tip" text="Question" /> |
| 33 | + |
| 34 | +MyHealth magazine is sold at RM5 each if at least 5 units of the magazine are purchased, and it is sold at the price of RM7 each otherwise. Calculate the price a customer has to pay after he enters the quantity of the magazines that he purchased. |
| 35 | + |
| 36 | +### Scenario 2 - Library Books <Badge type="tip" text="Question" /> |
| 37 | + |
| 38 | +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 based on the number of overdue days is applied. |
| 39 | + |
| 40 | +### Scenario 3 – Electricity Bill <Badge type="tip" text="Question" /> |
| 41 | +A utility company charges RM 0.30 per kWh for the first 100 kWh, RM 0.50 per kWh for the next 100 kWh (101–200 kWh), and RM 0.75 per kWh for any usage above 200 kWh. |
| 42 | + |
| 43 | +Calculate the total bill when the customer enters their total kWh consumed. |
| 44 | + |
| 45 | +### Scenario 4 – Income Tax Slab <Badge type="tip" text="Question" /> |
| 46 | +Income tax is applied as: |
| 47 | + |
| 48 | +- First RM 50 000 → 0% |
| 49 | + |
| 50 | +- Next RM 50 000 → 1% |
| 51 | + |
| 52 | +- Above RM 100 000 → 2% |
| 53 | + |
| 54 | +Given an annual income, calculate total tax due. |
| 55 | + |
| 56 | + |
0 commit comments