LabExe_Week9
LabExe_Week9
PART A
1. Nested IF can produce different outcomes based on each condition's evaluation (T/F)
3. IF-ELSE statement is necessary if there is only a single condition to evaluate and a single
4. A post-test iteration places the condition at the end of the loop (T/F)
5. A program that will calculate the car's devaluation at a rate of 8% per year for a period of
7. While loop is not capable to repeat more than one block of code at a time (T/F)
9. User interaction with a program can be implemented using selection control structure (T/F)
QUESTION 1
QUESTION 2
QUESTION 3
Number Guess is a game which ask user to guess a secret number within the range of 0 to
20. Users are only allowed to input integer within the range. The program will continue to
prompt the user for guesses until the correct number is entered.
a) Write a pseudocode using while loop for the program.
b) Given that the secret number is 12, predict the number of iterations if user entered the
following data: 2, 3, -15, 12,7
c) Suggest a way to implement for loop to develop the program instead of while loop.
QUESTION 4
Start
Set a = 0
Set b = 1
While b <= 5
Set c = 1
While c <= 3
Read ab
a = a + ab
EndWhile
c = c – 1
EndWhile
b = b – 1
Read “Total 15 numbers is:”, a
End
The purpose of the above pseudocode is to calculate the total of 20 numbers entered by the
user. Study the given pseudocode and find the errors occurred. State the error and suggest a
reasonable correction for each error.
QUESTION 5
A bookstore franchise has commissioned your company to develop a program for their online
ordering system. To start the program, customer should input their membership type (M –
Member OR N – Non-member). Customer will be able to view the catalog of available books
along with their respective prices as shown in the following table:
Then, prompt the user to enter the code of their chosen book and its quantity. Allow the user
to add more items to their order. Available payment methods are cash, online transfers, and
credit/debit card. Every cashless payment will get a 10% discount on the total purchase
amount. Members will be entitled to an additional 15% discount.
Before the check-out process, customers must choose the shipping method. They can
personally collect their orders from the bookstore without any additional charges. However, if
they prefer to have their orders shipped, the cost of shipping will differ based on the type of
shipping method. The full shipping cost will be added to the overall amount calculated after
applying discounts and tax.
Shipping Cost (RM)
Self-Collect No charge
Delivery 20.00 for each order
Upon exiting the program, display the final total amount of the book order including 6% tax.
The program will calculate the total amount to be paid for each order and generate the receipt.
The receipt should contain the same information as shown below. Please display necessary
instructions to customers. Below is the sample input and output for the program. The examples
of input values are represented in italics.
Choose membership type (M - Member | N - Non-member): M
***************Book Catalog*********************
Code Title Price (RM)
CN01 Mandarin: Beginner 35.00
EN05 Cooking with Hilda 120.00
CB10 ABC to Z 12.00
BZ78 Twinkle to Shine 119.00
************************************************
b) Identify the process/es which require sentinel value. Then state the sentinel value.
c) Calculate the total amount to be paid after discount if the customer is a non-member
and paying with credit card. Customer also choose to collect their order at the
bookstore. The books purchased are as follows:
Book code Title Price (RM) Quantity
CN01 Mandarin: Beginner Level 1 35.00 2
EN05 Cooking with Hilda 120.00 1
CB10 ABC to Z 12.00 1