3rd Prep Language Computer Booklet - First Term 2023- 2024
3rd Prep Language Computer Booklet - First Term 2023- 2024
PREP 3
Index
CHAPTER 1 : Problem Solving
Problem solving
Problem solving stages
Flow chart
Simple flow chart
The use of Branching (Decision) in Flowcharts.
The use of Loop in Flowcharts.
Significance Symbol
Terminal
(process)
(Decision)
(Flow lines)
1- Start
Start
2- Enter A and B
Enter A and B
3- C = A + B C=A+B
4- Output C Output C
5- End
End
1. The flowchart should start with the Start symbol and end with the End symbol.
2. A,B,C are variable names .The variable refers to a memory storage that holds a value.
3. Equation: C =A+B, indicates the sum of the value of A, to the value of B, and stores the
result in C.
4. Entering values in A and B is done by using the term “Enter”, inside a parallelogram,
like “Read” or “Input”.
5. The sum equation is written inside the rectangle, as it represents an
arithmetic operation.
6. The output is expressed with a parallelogram using the term “Output”, we
can also use another term like “Print” or "output".
7. Note that flow line shows the order of an Algorithm.
Exercise (2):
Draw a flowchart to solve a first degree equation Y=3X+2
First: Define the problem
Output: The value of Y
Input: X
Processing (Solution): Compute the value of “Y” from the equation Y=3x+2
Note
1. The left hand side (LHS) of any equation should contain only one variable; the value
of this variable will be the (output) or the solution of the equation.
2. The right hand side (RHS) of the equation may contain abstracted values or
arithmetic expressions that have one or more variables (inputs).
3- Y = 3*X + 2 Input X
4- Print Y
Y = 3*X + 2
5- End
Print Y
End
Exercise (3):
Write down the algorithm, and draw a flowchart to compute the area and the
perimeter of a rectangle whose length (L) and width (W) are known, bearing in mind
that the equation of the area is: Area =L*W and that of the perimeter is:
Perimeter=2*(L+W).
1- Start Start
2- Enter L, W
3- Area = A*W Enter L, W
Perimeter = 2*(L+W)
4- Print Area and Perimeter Area = A*W
Perimeter = 2*(L+W)
5- End
End
6 ﻳﺎﲰﲔ ﺷﻌﻴﺐ. ﺟﺮﻭﺏ ﻓﺮﻳﻖ ﺃﺻﺪﻗﺎء ﺍﻟﻜﻤﺒﻴﻮﺗﺮ – ﺃ/ ﺇﻋﺪﺍﺩ ﻭﺗﺼﻤﻴﻢ
Exercise (4):
Write down the algorithm, and draw a flowchart to compute the area of a circle whose
radius R is known, bearing in mind that the equation of the area of circle is:
Area=3.14*R*R.
First: Define the problem
Output: Area
Input: R
Solution: Area =3.14*R*R.
Second: Algorithm Third: Flowchart
1- Start Start
2- Enter R Enter R
5- End End
Exercise (5):
Write down the algorithm, and draw a flowchart to calculate the number of years,
bearing in mind that the number of months is known.
First: Define the problem
Output: Years
Input: Months Solution: Years = Months / 12
Second: Algorithm Third: flowchart
1- Start
Start
2- Enter Months
Enter Months
3- Years = Months / 12
Years = Months / 12
4- Print Years
Print Years
5- End
End
7 ﻳﺎﲰﲔ ﺷﻌﻴﺐ. ﺟﺮﻭﺏ ﻓﺮﻳﻖ ﺃﺻﺪﻗﺎء ﺍﻟﻜﻤﺒﻴﻮﺗﺮ – ﺃ/ ﺇﻋﺪﺍﺩ ﻭﺗﺼﻤﻴﻢ
Second: The use of Branching (Decision) in flowcharts
There are many problems that contain a question requires a Yes or No, or requires
branching to other processes determined by flowchart
Exercise (1):
Draw a flowchart to print the word "successful" In the case of the degree input is
greater than or equal to 50?
Yes
5- End X >= 50
No
Print Successful
End
Exercise (2):
Draw a flowchart for a program that will calculate the division of two numbers. if the
divisor equals (zero), the message displays " undefined".
3- Print “undefined”
Enter num2
4- Go to step 7
5- R=num1/num2 True
Num2 = 0
6- Print R
7- End False
Print “undefined”
R = num1/num2
Print R
End
Exercise (3):
Draw a flowchart for a program that obtains a number from the user. Determine the
number type (even or odd) and print the result?
First: Define the problem
Output: print the number type (even or odd).
Input: the number “N”.
Solution: The even number is determined if the entered number is divisible by 2
without remainder, otherwise it will be odd
Second: Algorithm
1- Start
2- Enter N
3-If N is divisible by 2 without remainder then
3-1 Print “even number”
4- Else
4-1 Print “odd number”
5- End
9 ﻳﺎﲰﲔ ﺷﻌﻴﺐ. ﺟﺮﻭﺏ ﻓﺮﻳﻖ ﺃﺻﺪﻗﺎء ﺍﻟﻜﻤﺒﻴﻮﺗﺮ – ﺃ/ ﺇﻋﺪﺍﺩ ﻭﺗﺼﻤﻴﻢ
Third: flowchart
Start
Get N
Yes N No
divisible
by 2
Print even
Print odd
number
number
End
Exercise (4):
Draw a flowchart to Get a temperature degree, and print out the following result
“greater than zero" – " less than zero " –"equal zero”
First: Define the problem
Output: Print out “greater than zero” – “less than zero “or “equal zero”.
Input: Temperature degree Celsius “D”.
Solution: The temperature degree entered will be compared to zero
Second: Algorithm
1- Start
2- Enter D
3- If D = 0 Then
3-1 Print Equal 0
4- Else
4-1 If D < 0 Then
4-1-1 Print Below 0
4-2 Else
4-2-1 Print Above 0
5- End
10 ﻳﺎﲰﲔ ﺷﻌﻴﺐ. ﺟﺮﻭﺏ ﻓﺮﻳﻖ ﺃﺻﺪﻗﺎء ﺍﻟﻜﻤﺒﻴﻮﺗﺮ – ﺃ/ ﺇﻋﺪﺍﺩ ﻭﺗﺼﻤﻴﻢ
Third: flowchart
Start
Get D
True
D=0
End
Exercise (5):
Write down the Algorithm, and draw a flowchart to enter two unequal numbers , then
print " the largest is ……?" "and, " the smallest is…..?
Output: print out “the largest number is ...? “– “the smaller number is .…? “
Input: X, Y so x not equally
Solution: the X will be compared to Y
Second: Algorithm
1- Start
2- Input X,Y so x not equal y
3- If X > Y Then
3-1 Print out “the largest number is X , the smaller number is Y
4- Else
4-1 Print out “the largest number is X , the smaller number is Y
5- End
False True
X>Y
End
Exercise (6):
The following flowchart is used to calculate the Area of a circle with radius "R".
Redraw the flowchart so that it displays the message" not allowed" and exits from the
program (when the value of "R" is negative")
Start
Start
Enter R
Enter R
True
R<0
Area = 3.14*R*R
False Print
Not Allowed
Print Area
Area = 3.14*R*R
End
Print Area
End
12 ﻳﺎﲰﲔ ﺷﻌﻴﺐ. ﺟﺮﻭﺏ ﻓﺮﻳﻖ ﺃﺻﺪﻗﺎء ﺍﻟﻜﻤﺒﻴﻮﺗﺮ – ﺃ/ ﺇﻋﺪﺍﺩ ﻭﺗﺼﻤﻴﻢ
Third : The use of iterative loops in flowcharts:
Exercise (1) :
1- Start Start
2- M=1
M=1
3- If M<=3 Then
False
M<=3
3-1 Print M
True
3-2 M=M+1 Print M
J=1
False
J<=12
True
Print J*3
J=J+1
End
Exercise (3):
Print the multiplication table of any number?
2- Enter N
Enter N
3- J=1 J=1
4- If J<=3 Then
J<=12 False
4-1 Print J*N
5- End
J=J+1
End
14 ﻳﺎﲰﲔ ﺷﻌﻴﺐ. ﺟﺮﻭﺏ ﻓﺮﻳﻖ ﺃﺻﺪﻗﺎء ﺍﻟﻜﻤﺒﻴﻮﺗﺮ – ﺃ/ ﺇﻋﺪﺍﺩ ﻭﺗﺼﻤﻴﻢ
Exercise (4):
Write down the Algorithm and draw a flowchart to print out even numbers from 2 to
10
Second: Algorithm Third: flowchart
1- Start Start
2- M=2
M=2
3- If M<=10 Then
4- End
M=M+2
Exercise (5): End
Print out the sum of integer numbers from 1 to 3?
Second: Algorithm Third: flowchart
1- Start
Start
2- N = 1
3- Sum = 0 N=1
4- Sum = Sum + N
Sum = 0
5- N = N + 1
6- If N > 3 Then Sum = Sum + N
6-1 Print Sum
N=N+1
7- Else
7-1 Go to step 4
No
8- End N >3
Yes
Print Sum
End
15 ﻳﺎﲰﲔ ﺷﻌﻴﺐ. ﺟﺮﻭﺏ ﻓﺮﻳﻖ ﺃﺻﺪﻗﺎء ﺍﻟﻜﻤﺒﻴﻮﺗﺮ – ﺃ/ ﺇﻋﺪﺍﺩ ﻭﺗﺼﻤﻴﻢ
Exercise (6):
Redraw the flowchart of the previous exercise in your notebook after modifying it to
print out the sum of odd numbers from 1 to 10
2- N = 1
N= 1
3- Sum = 0
5- N = N + 2 Sum = Sum + N
6- If N > 10 Then
N= N+2
6-1 Print Sum
No
7- Else N > 10
Print Sum
8- End
End
a. Problem
b. algorithm
c. flowchart
Form window before putting controls Form window after putting controls
2- Toolbox Window:
It contains tools of controls which can be put on the Form and
can be shown in categories in the following Figure
4- Solution Explorer
There is a list of folders and files of the projects in this part as shown in this
Figure:
Solution
Name
Folders and
files for first First Project
project
Second Project
Folders and
files for second
project
In design
mode and
Text ﻣﺴﺎﺣﺔاﻟﻤﺮﺑﻊ
runtime
mode
In design
mode and
Color DarkSeaGreen
runtime
mode
In design
mode and
RightToLeft Yes
runtime
mode
In design
RightToLeftLayout True mode and
runtime mode
In design
MaximizeBox False
mode and
MinimizeBox False
runtime mode
In design
ControlBox False mode and
runtime mode
In design Note
FormBorderStyle None mode and
the
runtime mode
Property
N Function
Name
1 Location The location of placing Button on the Form.
Backcolor Yellow
Forecolor Blue In design mode and
runtime mode
Text اﺣﺴﺐ
Note: - You can change the size of Label manually by using the process of drag and
drop when the Value of the property Auto Size is false through the eight handles in
design mode only and its effect appears in design mode and runtime mode.
:اﻟﻨﺘﻴﺠﺔ
Text
Forecolor Choosing an
Backcolor appropriate color
Font Choosing an
AutoSize appropriate color In design mode and
BorderStyl Choosing the runtime mode
e Size, Style and
Type of the
appropriate Font
False
FixedSingle
Textbox
It is a tool used to insert (input) data from the user during program run time.
Property
N Function
Name
It defines the maximum number of letters which can be
1 Maxlength
inserted in the TextBox
It defines a symbol used instead of written text in case
2 PasswordChar
we have a password.
3 Multiline Allows multiple lines within the text box control tool.
Writing in
multiline
ListBox
It shows a list of items.
Some distinctive properties of ListBox:
Appearance
Property mode of Form Window after setting the
Name Value property property
effect
ﻋﻤﺮو
راﻣ In design and
Items Names sorted
ﻳﺎﺳﻤﻴﻦ runtime mode
ﺳﻤﺮ alphabetically
SelectionMode Multiextended In runtime mode Select more
than one item
In design and
Sorted True
runtime mode
ComboBox
A ComboBox control displays a drop-down list from which one item can be selected.
Some distinctive properties of the ComboBox:
Choose
In design mode and
Forecolor the Red
runtime mode
color
In design mode and
RightToLeft yes
runtime mode
Radio Button
The program user selects one alternative only.
Some distinctive properties of the RadioButton:
In case of placing a group of Radio Buttons and set the text
property to each one of them in design mode as it is shown in the
following Figure:
During program runtime, you can select one Radio Button only as
it is shown in Figure:
You can use Group Boxes such that each group has a title and
the user is allowed to choose one alternative from each group as
it is shown in the following Figure:
Check Box
It is used for placing some alternatives to enable the user to select one Check Box
or more as shown in Figure:
During program runtime, you can select more than one Check Box.
Questions
Choose the correct answer to complete each statement:-
1- The function of "Right to Left" property of the Form is:
a- Define the direction of Control tools from Right to Left.
b- Define whether the layout of ControlTools on the Form is from Right to Left.
c- Define the state of the window in a state of maximaizing or minimaizing.
2- The Object TextBox is marked by one property :
a- AutoSize
b- Name
c- PasswordChart
3- The property responsible for the shape, size, and font effect of the text appearing
on the command button is:
a- backcolor.
b- forecolor.
c- font
4- You can change the position of the command button on the Form window
through the following operations except:
A- Drag and drop using the mouse.
B- Set the size property.
C- Set the Location property
7- The size of the Label widget is automatically determined on the form window if
the property is:
a. AutoSize = False
b. BorderStyle= FixedSingle
c. AutoSize=True
8- The size of Label is defined manually on the Form if the property is:
a- AutoSize = False
b- BorderStyle= FixedSingle
c- AutoSize=True.
9- the following properties are all for the TextBox control except the property
a- autosize
b- multiline
c- maxlenght
10- The right value which can be used to set the PasswordChart of the TextBox is :
a- Pw
b- True
c- *
Code Window
(1) Name of the file where codes are saved
(2) Name of the file where the Form window interface is saved
(3) The declaration of Class; its name is (Form1)
(4) Space between two lines; to type codes for the Class (Form1)
(5) The end of the class (form 1)
Event Handler
It’s a procedure which contains a code that is carried out when a corresponding
event occurs.
To create Event Handler do the following steps:
1. In the (Solution Explorer) window, right click the file (Form1.vb) and, select (View
Code) from the context menu as shown in this figure:
(1) A drop-down menu of (Class Names) that displays the names of controls on the
form.
(2) A drop-down menu of (Method Names) or events; associated with the item
selected from the (Class Names) menu.
2. Open (Class Name) menu and note that the default names of the controls are
listed as shown in this figure.
3. When you select (Button1) from the Class menu drop down list, open (Method
name) menu it displays the events associated with (Button1).
4. Choose the required event from the drop-down menu (Event handler).
Event Handler
Adjust the property (Name) for the following controls as shown in table:
Write the following code in the appropriate event handler (Bu on1_Click) for bu on1:
End Sub
Question
1. Explain the components of the general syntax to adjust the properties of controls
programmatically:
ControlName.Property = Value
2. Explain the following codes through your pervious study for the general syntax to
adjust the properties of control programmatically :
(A) Bu on2.Text = "END"
……………………………………………………………………
(B) Label1.AutoSize = True
……………………………………………………………………
36 ﻳﺎﲰﲔ ﺷﻌﻴﺐ. ﺟﺮﻭﺏ ﻓﺮﻳﻖ ﺃﺻﺪﻗﺎء ﺍﻟﻜﻤﺒﻴﻮﺗﺮ – ﺃ/ ﺇﻋﺪﺍﺩ ﻭﺗﺼﻤﻴﻢ
Model
Answer
2. Explain the following codes through your pervious study for the general syntax to
adjust the properties of control programmatically :
(A) Bu on2.Text = "END"
…………………… Show the word End on the face of the button tool………………………
(B) Label1.AutoSize = True
Zoom in and out of the Title widget according to the size of the text displayed in it
40 ﻳﺎﲰﲔ ﺷﻌﻴﺐ. ﺟﺮﻭﺏ ﻓﺮﻳﻖ ﺃﺻﺪﻗﺎء ﺍﻟﻜﻤﺒﻴﻮﺗﺮ – ﺃ/ ﺇﻋﺪﺍﺩ ﻭﺗﺼﻤﻴﻢ