Skip to content

Chapter 2 - Tutorial 2

Creating The IPO Table Recall

PhasePractical MeaningTypical Keywords (in the problem text)
InputData accepted from the user — always nouns, never actions. NEVER USE VERB.enter, read, get
ProcessOperations applied to the inputs — arithmetic, decisions, loops. Each item should begin with a verb.

The suggested structure is:

VERB + OUTPUT + BASED ON INPUT AND CONSTANT
calculate, compute, determine, if, while, repeat
OutputThe result delivered to the user or another system — again nouns or messages. NEVER USE VERB.display, print, show

Scenario 1 - Simple Scenario Question

  1. Calculate the area of a circle if the radius is a positive value.
  2. Calculate the 10% tax on a product if the price is greater than RM200.00.
  3. Check if a student has passed or failed based on their exam score:
    • If the score is greater than or equal to 50, display "Passed."
    • Otherwise, display "Failed."
  4. If the person is 18 years or older, display the message "Eligible to vote". Otherwise, display the message "Not eligible to vote".
  5. Determine whether the number entered by the user is positive, negative or zero.
  6. Calculate phone bill based on the following terms:
    • Usage less than RM50.00 per month: no discount will be given
    • Usage less than RM100.00 per month: get 5% discount
    • Usage RM100.00 and above per month: get 20% discount

Scenario 2 - Bookstore Price Question

A bookstore is offering discounts based on the price of books:

  • If the price of a book is less than RM50.00, apply a 5% discount.
  • If the price is between RM50.00 and RM100.00 (inclusive), apply a 10% discount.
  • If the price is greater than RM100.00, apply a 20% discount.

Calculate the discount amount based on the price of a book.

Scenario 3 - Utility Charge Question

A utility company charges for electricity based on usage. The rates are as follows:

  • If usage is less than 500 watts, the charge is RM0.50 per watt.
  • If usage is between 500 and 1000 watts (inclusive), the charge is RM0.45 per watt.
  • If usage is greater than 1000 watts, the charge is RM0.40 per watt.

Calculate the electric bill based on the usage (in watts) provided.

Scenario 4 - Gym Membership Question

A gym offers membership fees based on the membership type. If the membership is a premium membership, a 25% discount will be applied. If the membership is a standard membership, a 15% discount will be applied. If the membership is a basic membership, a 5% discount will be applied. Calculate the price after the discount based on the type of membership.

Scenario 5 - Hotel Price Question

A hotel is applying tax on room prices based on the room rate. If the room rate is greater than RM200.00, a 15% tax will be applied. If the room rate is between RM100.00 and RM200.00 (inclusive), a 10% tax will be applied. If the room rate is RM100.00 or less, a 5% tax will be applied. Calculate the price after tax for the customer based on the room rate.

Scenario 6 - Coffee Subscription Question

A café sells a monthly coffee subscription that includes 15 cups. After that, each extra cup costs:

Cumulative Cups Extra-Cup Price

  • 16-25 : RM4.00 each
  • 26-35 : RM3.00 each
  • 36+ : RM2.00 each

Scenario 7 - Cinema Loyalty Pass Question

A cinema loyalty pass gives one free ticket every Tuesday or one free ticket any day once you've spent RM200.00 that month—whichever happens first. Tickets cost RM18.00. A member buys tickets on:

  • 1st (Jan) : 3 tickets
  • 7th (Jan, Tue) : 2 tickets
  • 14th (Jan, Tue) : 4 tickets

Released under the MIT License. All rights reserved.