Programming III
Programming III
Science O.L.
(New Syllabus)
01
Programming pt.3
(Conditional)
Programming pt.3
● Conditional statement
● Validation
Programming Concepts
Programming is built on 3 main concepts
ELSE
ENDIF
Conditional statement
How to develop the Condition for computer logic
Computer Only understands numbers by comparison
ENDIF
Screen
Quick question
Write a program that take from user his age and
Print weather he is adult or not
Code
Screen
Quick question
Create a program that ask the user to enter number and
show if it is zero or not.
Code
Screen
Quick question
Design a program that take from the user his height in
CM an decide whether he is “Tall” Or “Short”
Tall users are more than 175 cm.
Code
Screen
Quick question
-Extend the previous program as if the user considered
Tall the show his height in meters ( 100cm: 1Meter) ,and if the
user is considered Short the show his height in inches( 1 inch:
2.54 cm).
Code
Logic statement
Its tool to combine two statements in one condition
AND OR
True Only if the two statements are true ,False True Only if the two statements are true or either
otherwise of them, False otherwise.
ELSE ELSE
ENDIF ENDIF
Screen
Quick question
Create program to enter quiz grade as if grade is between 70 to
100 then show “Great” as a message otherwise, show “need to
study”
Code
Screen
Quick question
Design a program that inputs a number and prints “Correct
range” if the number is between 1 and 20 (inclusive) or between
-1 and -20 (exclusive), otherwise the program outputs “Wrong
range”.
Code
Re-Call
Flowchart
Screen
Quick question
Design program that show “You’re bluffing “in case user entered
his age less than 0 also if he entered age more than 100,
otherwise show “you are good”.
Code
Validation
It is a process of filtering data that user control from insensible data
Code
Screen
Quick question
Design a pseudocode that will read the side length of a square and displays its perimeter and
area.
Note that
The perimeter = 4*side
The area = side * side
Display an error message if the side length is negative.
Code
Screen
Quick question
Design an algorithm that inputs a sphere's radius from the user and the
program calculates the surface area and then outputs the result.
Note that the surface area = 4*π*radius2 (π = 3.14)
Validate the inputs.
Code
Screen
Quick question
Create program that convert from minutes to hours, and print
the time in hours
Validate the inputs.
Code
Screen
Test
Design a program that inputs a binary digit from the user. The program
should output ON and OFF in case the user entered 1 and 0 respectively.
In case the user entered any other value than 1 or 0, the
program must display an error message.
Code
Next Session
Programming pt.4
HW
THANKS