# data[].attributes.body
Write “Enter weight of package in Kilograms”

Read Weight

If weight > =  100 then

Write “Heavy”

Else if weight < 60 then

Write “Light”

Else

Write “Medium”

Else weight <=0 than quit program

Write “Program Ended”

# data[].attributes.body
Q2:

Write “enter the weight value”

Read numweight

Set numweight to 1

While(numweight !=1)

If(numweight>=100)

Print “heavy”

Else if(numweight >=60) &&( numweight <=100)

Print “medium”

Else if(numweight<60)

Print “light”

Else

Print “programs end”

# data[].attributes.body
Q1

Following are the constructs which are represented in a Pseudocode algorithm :

Variebles:-

Name of places used to store different values.

Assignment :

Used to store a value in Variebles.

Output :

Printing/Getting a value on a output device.

e.g # Write, Print,  Write “Err,  Write sum

Input :

Getting values from users/Outside word and to store them into variables.

Repetation :

Repeating a series of the same statements in a Pseudocode algorithm.

Selection :

Choose to execute a statement or another statement based on a given condition.

# data[].attributes.body
Q1
Variables: The name of places to store value

Assignment: Storing the value of an expression into a variable

Output: Printing a value on an output device

Input: Getting values from the outside word and storing them into variables

Repetition: Repeating a series of statements

Selection: Making a choice to execute or skip a statement/Choose to execute oone statement or another statement

Q2
Write”Please enter a weight of package(1-100 Kilogram)”

Read weightOfPackage

WHILE weightOfPackage<>0

IF weightOfPackage >=100 then

Write”Heavy”

ELSE IF (weightOfPackage >=61) AND (weightOfPackage <=99) then

Write”Medium”

ELSE

Write”Light”

Q3
Write”Enter the price of item 1”

Write”Enter the price of item 2”

Read PriceOfItem1

Read PriceOfItem2

Set totalPrice to 0

WHILE (priceOfItem1>0) OR (priceOfItem2>0)

IF totalPrice>85 then

Write”Discount RM10”

ELSE IF totalPrice>70 and      totalPrice<85 then

Write”Discount RM5”

ELSE

Write”No discount”

Stop

# data[].attributes.body
Q2:

WRITE “Please enter your weight (0-100).”

READ weight

WHILE (weight <> 0)

IF (weight > 100) THEN

PRINT “Heavy”

ELSEIF (weight >= 61 AND weight <= 99) THEN

PRINT “Medium”

ELSEIF (weight >= 0 AND weight <=60) THEN

PRINT “Light”

WRITE “Please enter your weight (0-100).”

READ weight

Q3:

WRITE “Please enter the prices of 2 items to get discount.”

READ Price1, Price2

WHILE (Price1 > 0 AND Price2 > 0)

SET TotalPrice TO Price1 + Price2

IF (TotalPrice > 85) THEN

WRITE “Discount RM10”

ELSEIF (TotalPrice > 70 AND TotalPrice < 85) THEN

WRITE “Discount RM5”

ELSEIF (TotalPrice < 70)

WRITE “No Discount”

WRITE “Please enter the prices of 2 items to get discount.”

READ Price1, Price2

# data[].attributes.body
Q3:

Amount1 = 0

amount2 = 0

While (amount1 > -1)

Write “enter item first amount?”
Read amount1

Write “Enter item second amount?”

Read amount2

Total = amount1 + amount2

If (total > 85)

Write “Discount RM10”

Else if (total > 70 and total =< 85)

Write “Discount RM5”

# data[].attributes.body
Write "please enter the weight (1-100): "
Read weight

While (weight <>0)
if weight >=100 then
write "heavy"
else if weight < 60 then
write "light"
else
write "medium"

# data[].attributes.body
Q1:
Variables

Names of places to store values

quotient, decimalNumber, newBase

Assignment

Storing the value of an expression into a

variable

set

Output

Printing a value on  an output device

Write, Print

Input

Getting values from the outside word and storing them into variables

Get, Read

Repetition

Repeating a series of statements

while

Selection

Making a choice to execute or skip a statement (or group of statements)

If/else if/else

# data[].attributes.body
Write "Enter a weight of package 1-100"

Read numberOfPackage

While(weight<>0)
IF( number > 100)
write('heavy')
Else  IF(61 < weight<99)
write('medium
Else IF (weight <60)
write('light')

# data[].attributes.body
1)
- Inner levels must be indented
To show order of statements carried out (Innermost levels executed first)
- May contain:
variables (data storage locations)
assignment (variables with a preset value)
input (data entered by user)
output (processed info shown to user)
repitition (loops)
selection (if/else statements)

2)
Write "Enter weight of package (1 - 100kg): "
Read packageWeight
WHILE (packageWeight <> 0)
IF (packageWeight > 100)
Write "heavy"
ELSE IF (packageWeight > 60) and (packageWeight < 100)
Write "medium"
ELSE IF (packageWeight < 60)
Write "light"

Write "Enter weight of package (1 - 100kg): "
Read packageWeight

3)
Write "Enter price of Item 1: "
Read item1
Write "Enter price of Item 2: "
Read item2

WHILE item1 >= 0 AND item2 >= 0
Set totalPrice to (item1 + item2)
IF totalPrice > 85
Write "Discount RM10"
ELSE IF totalPrice > 70
Write "Discount RM5"
ELSE
Write "No Discount"

Write "Enter price of Item 1: "
Read item1
Write "Enter price of Item 2: "
Read item2

# data[].attributes.body
Q2)

PROMPT “Insert your number 1-100)”

Read Num1

While (num1 > 0)

IF (num1<100)

Write “heavy”

ELSE (num1 > 61 and => 99)

Write “medium”

ELSE (num1 < 60)

Write “light”

Q3)

PROMPT user to input price1 and price2

READ price1, price2

SET totalprice = 0

While price1 >= 0 and price2 >= 0

SET totalprice = price1 + price2

IF totalprice > 85

WRITE “Discount RM10”

ELSE totalprice > 70

WRITE “Dsicount RM5”

ELSE totalprice < 70

PROMPT user to input price1 and price2

IF total price < 0

STOP

# data[].attributes.body
Variables: Names of places to store values.

Assignment: Storing the value of an expression into a variable

Output: Printing a value on an output device

Input: Getting values from the outside word and storing them into variables

Repetition: Repeating a series of statements

Selection: Making a choice to execute or skip a statement

Q2.

WRITE “Enter Your Weight(0-100kg)”

Read weight

IF (weight>100)

Print “Heavy”

ELSE

IF (weight>=61)

Print “Medium”

ELSE

IF (weight<61)

Print “Light”

ELSE

Print “Please Check Your Weight.”
Q3.

WRITE “Enter two item prices”

READ price1

READ price2

SET Totalprice to 0

SET Totalprice TO price1+price2

IF (Totalprice < 0)

Write “Please Check Your Item Price.”

IF (Totalprice > 85)

Write “Discount RM10”

Else

IF (Totalprice > 70)

Write “Discount RM5”

Else

IF (Totalprice <70)

Write “No Discount”

LCF

# data[].attributes.body
2.
Write "please enter the weight (1-100):
Read weight
While (weight<>0)
if weight> =100 then
print "heavy"
else if weight < 60 then
print "light"
else
print "medium"
3.
Write "enter the price of two items as an integer: "
Read item1
Read item2
Set totalprice=0
While item1>=0 and item2>=0
Set totalprice= item1+item2
If totalprice>85
Print "discount RM10"
Else if totalprice>70
Print "discount RM5"
ELSE
Read item1
Read item2
If totalprice<0
STOP

# data[].attributes.body
Q1:

Variables, assignment, output, input, repetition, selection

Q2:
write ("user please input a weight(1-100)?")
read weight
while (weight <>0)
if weight>=100 then
write ("heavy")
else if weight>=61 and weight<=99
write ("medium")
else
write ("light")
Q3:

set price1 = 0

set price2 = 0

While (price1 > -1)

Write “enter item one’s price?”
Read price1

Write “Enter item two’s price?”

Read price2

Total = price1 + price2

If (total > 85)

Write “Discount RM10”

Else if (total > 70 and total =< 85)

Write “Discount RM5”

Else

Write “No Discount”

# data[].attributes.body
1. input
Q3.
set value0
a,b=input(set integer)
total=a+b
if total price >  85
then print"Discount10RM"
if total price > 70
then
print "DiscountRM5"
else
total price <70
print "no discount"

# data[].attributes.body
1.

Variables – Name of places to store values.

Assignment – Storing the value of an expression into a variable

Output – Printing a value on an output device

Input - Getting values from the outside word and storing them into variables

Repetition – Repeating a series of statement

Selection – Making a choice to execute or skip a statement

2.  Ans: Write “Enter weight”
Read New Weight
While (weight <> 0 )
IF weight >=100 then
Write “Heavy”
Else if weight >=61 and weight <=99 then
Write “Medium”
Else if weight <60 then
Write “light”
Else “Medium”

3.Write “Please enter price of item 1”
Read item1
If (item1<0)
Write item1+ “is less than 0.”
Write “Please input an appropriate value”
Write “Please enter price of item 2”
Read item2
If (item2<0)
Write item1+ “is less than 0.”
Write “Please input an appropriate value”
While item1>0 or item2>0
Set totalPrice to 0
Set totalPrice to item1 + item2
Read totalPrice
If (totalPrice > 85)
Write “Discount RM10”
Else if (totalPrice>70)
Write “Discount RM5”
Else
Write ”No discount”

# data[].attributes.body
Variable – name of place to store values .

Assignment – storing the value of an expression into a variable .

Output – print the result .

Input – get values from user .

Repetition – repeat a series of statements .

Selection – make a choice to execute or skip a statement .

# data[].attributes.body
Question 1
Variables - The names of places to store variables
Assignment - A variable with a stored value
Output - printing a value on an output device
Input - getting values from outside the code and storing it in variables
Repetition - repeating a series of statements
Selection - deciding whether or not to skip or execute a statement
Question 2
Write "Enter the weight of a package"
Read packageWeight
While (packageWeight /= 0):
if (packageWeight > 100):
write "Heavy"
else if (packageWeight <= 99) and (packageWeight >= 61):
write "Medium"
else:
write "Light"
Stop
Question 3

# data[].attributes.body
Adiilah Zaini / Raveena
1.
Variable (Decimal, Number)
- name of place to store value

Assignment (Set, quotient)
- same as variable but with value.

Output (Print, Write)
- result / print value of output or result.

Input (Get, read)
- values from outside word & storing data (get variable)

Repeating (While)
Repeating series

Selecting ((if), (else if), (nested if))
- execute or skip a statement
2.

Write “Enter the weight of package “

Read weight

While (weight <> “0”)

If (weight > 100)

write “Heavy”

Else if

If (weight >= 61) and (weight <= 99)

write “Medium”

Else

Write “light”
3.

Write “Enter a price for two item separated with blank”

Read Price1

Read Price2

Set total price to “0”

While (Price 1 >= 0) and (price2 >= 0)

Set totalprice to (price1 + price2)

If totalprice > 85

Write “discount rm 10”

Else if

Totalprice >70

Write “discount rm 5”

Else

Write “ No Discount”

# data[].attributes.body
Write 'Enter two price separated with blank'

Read Price1 , PRice 2

Set TotalPrice to 0

While (price1 >0 )OR (Price2 >0)
Set TotalPrice to Price1 + Price2

if TotalPrice >85:
Write 'DiscountRM10'

ELSEIF TotalPrice > 70:
Write"DIscountRM5'

ELSE
'NoDiscount'
Write 'Enter two price separated with       blank'

Read Price1 , PRice 2

# data[].attributes.body
1.
A. Variable = Names of places ti store values
B . Assignment = storing the value of an expression
Into a variable
C. Output= printing a value on an output devices (ex:print)
D. Input = getting values from the user and storing them into variables (ex command = Read)
E. Repetition = repeating a series of statements (command = while)
F. Selection = making a choice to excecute or skip a statement (command = If , elseif , else)