Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
24 views6 pages

LabExe Week10

Uploaded by

Hizal Haziq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views6 pages

LabExe Week10

Uploaded by

Hizal Haziq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

LAB EXERCISE - WEEK 10

PART A

Answer TRUE (T) OR FALSE (F) for the following questions.


1. A process in problem solving consists of the steps to produce the output. (T/F)

2. Pseudocode shows the logic in problem solving graphically. (T/F)

3. Relational operators compare numeric, character string, or logical data. (T/F)

4. Only one condition must be true for execution using AND operator. (T/F)

5. Control structures determine how different sections of code are executed. (T/F)

6. There is no minimum number of iteration for do..while loop. (T/F)

7. Boolean comparison evaluates the decision that controls every loop. (T/F)

8. Nested Ifs are used to check multiple independent decision criteria. (T/F)

9. If…else if…else structure represents dual alternative selection. (T/F)

10. Categories of control structures are sentinel, selection, and repetition. (T/F)

1. 6.
2. 7.
3. 8.
4. 9.
5. 10.
PART B

QUESTION 1

Program Development Life Cycle (PDLC) is a systematic process which contains several phases
in developing computer programs. It ensures successful program development and meeting user
requirements.

List the phases in Program Development Life Cycle (PDLC), in the correct order.

QUESTION 2

The following pseudocode shows the algorithm to convert Malaysian Ringgit (MYR) to other
foreign currencies.

Start
Read myr, currency
IF (currency == usd)
a = myr * 4.0

(i) _______ (currency == eur)


a = myr * 5.2

ELSE IF (currency == jpy)


a = myr * 0.036
(ii) ________

Display "Please enter USD, EUR, or JPY only."


(iii) ________

Display” Converted amount: ", a


End

a) Find the right word to fill in the bank in the pseudocode above.

b) Convert the pseudocode into flowchart.

c) Predict the output from the algorithm if the value entered as follows:

myr 25.99
currency jpy

2
QUESTION 3

A repetition control structure or loop is a programming construct that allows a set of statements
to be executed repeatedly based on a specified condition.

a) Describe a difference between pre-test loop and post-test loop.


b) List the key requirements to develop a post-test loop.
c) Based on your answer in (b), draw the flowchart to show the execution of post-test loop.

QUESTION 4

Figure 1 below illustrates the steps of a calculation process.

Figure 1

a) Find the final value of x, y and total.


b) State the number of iterations for the algorithm.
c) What is the sentinel value of the loop. Justify your answer.

3
PART C

Sekolah Kebangsaan Ceria Selalu is creating a quiz program for Standard 1 students to learn
about alphabets and numbers. The program begins by welcoming the user and asking them to
start. If the user decides not to start the game, it will end. Users can choose between two quizzes:
Alphabets or Numbers. If the user makes a mistake, the program prompts them to enter the
correct quiz code.

Each quiz consists of two questions, and users must answer both. For each correct answer, the
program responds with "Correct! You earned 1 point" and increases the score by 1. If the answer
is incorrect, the program reveals the correct answer but does not award any points.

Table 1 below shows the list of the questions Alphabets quiz:

Table 1 Alphabets’ quiz

No Questions Accepted answers


1. What is the first letter of the alphabets? A or a
2. What is the last letter of the alphabets? Z or z

Table 2 below shows the list of the questions Numbers quiz:

Table 2 Numbers’ quiz

No Questions Accepted answers


1. What is the first number 1
2. What is 1 + 1 2

After completing a quiz, the total score will be displayed. Then, the user will be asked if they want
to continue with another quiz or stop the game. If the user chooses to stop the game, the
accumulated score from all quizzes will be displayed before the system shows a closing message.

4
Figure 2 below shows the sample output for the program.
Welcome to Alphabets and Numbers Quiz!

Do you want to play a game? [ Y / N ]: Y

Choose a quiz:
1. Alphabets
2. Numbers

Enter your choice (1 or 2): 1

Question 1: What is the first letter of the alphabets?


Your answer: A

**Correct! You earned 1 point. **

Question 2: What is the last letter of the alphabets?


Your answer: b

**Oppsss...The correct answer is Z or z.**

[ Your total score for Alphabets is: 1 / 2]

Do you want to play another game? [ Y / N ]: Y

Choose a quiz:
1. Alphabets
2. Numbers

Enter your choice (1 or 2): 2

Question 1: What is the first number?


Your answer: 0

**Oppsss...The correct answer is 1. **

Question 2: What is 1 + 1?
Your answer: 2

**Correct! You earned 1 point. **

[ Your total score for Numbers is: 1 / 2]

Do you want to play another game? [ Y / N]: N

----------------------------------------
Your overall total score is: [2]

Thank you for playing!


Figure 2

5
a) Draw a complete flowchart for the problem described above. Your solution must
include selection and repetition control structures.

b) With a correct indentation, write the section of pseudocode for Alphabets quiz only.
After both questions are answered, the program should display the total marks for the
quiz.

You might also like