Presentation is loading. Please wait.

Presentation is loading. Please wait.

Module 1 Problem Solving حل المسائل 1942102 Computer Skills for Humanities Lecturer: Dr. Mohammad Abd-Alrahman Mahmoud Abushariah

Similar presentations


Presentation on theme: "Module 1 Problem Solving حل المسائل 1942102 Computer Skills for Humanities Lecturer: Dr. Mohammad Abd-Alrahman Mahmoud Abushariah"— Presentation transcript:

1 Module 1 Problem Solving حل المسائل 1942102 Computer Skills for Humanities Lecturer: Dr. Mohammad Abd-Alrahman Mahmoud Abushariah E-mail: m.abushariah@ju.edu.jo m.abushariah@gmail.com m.abushariah@gmail.com

2 2 Chapter Objectives Presents the data types and explains the constants, variables, strings, …etc. Introduces the steps to solve a problem through flowcharts and pseudo codes. Explains constants, variables, and data types. Helps understanding and solving problems using MS-Excel and MS-Access in the following modules.

3 3 Data Types أنواع البيانات Data: is the main element of programming. يتم التعامل مع البيانات أو القيم في التطبيقات البرمجية على النحو التالي: 1- كتابتها مباشرة وهو ما نسميه الثوابت الصريحة.(Literal) 2- الإشارة إليها بإسم وهي المتغيرات (Variables) التي يتم تخزين القيم فيها لاحقا من خلال الإدخال أو جملة التخصيص. There are 4 common data types:  1) Strings  2) Integers  3) Real Numbers  4) Boolean

4 4 Data Types أنواع البيانات 1) السلاسل الرمزية(Strings):  Store a series of characters. هي مجموعة مكونة من رمز واحد أو أكثر مثل الرسائل والأسماء والترويسات وغيرها. عادة يتم وضعها بين علامتي تنصيص " " إذا إحتوت أكثر من رمز أو ' ' إذا إحتوت رمزا واحدا فقط، وتقسم إلى: الحروف الأبجدية: A, B, C, …, a, b, c, …, الرموز الخاصة: *, &, %, @, !, #, …, الأرقام:0, 1, 2, 3, …, 9

5 5 Data Types أنواع البيانات 2) الأعداد الصحيحة(Integers):  Represent complete integer values (positives and negatives). الأعداد الصحيحة تكتب كما هي من دون فراغ ومن دون فاصلة عشرية وجائز أن يسبقها إشارة العدد – أو +. أمثلة: 12, 6, -55, 114, +90

6 6 Data Types أنواع البيانات 3) الأعداد الحقيقية(Real Numbers):  Used to store real numbers using decimal points or exponential notations. تكتب بشكلين: بإستخدام الفاصلة العشرية: وتكتب فاصلة عشرية واحده فقط في العدد. مثل: 0.001, +54.3, -0.2 الصيغة العلمية: وهي ضرب العدد الحقيقي بالأساس 10 مرفوعا لأس معين. مثل: العدد 45423.5 يمكن كتابته بالشكل التالي 4.54235 x 10 4

7 7 Data Types أنواع البيانات 4) الثوابت المنطقية(Boolean):  Used to store Boolean values, which can be either True or False.  Sometimes 0 is used to represent False statements, whereas 1 is used to represent True statements.

8 8 Exercises Identify the most suitable data type for the followings: 1) statement = “Nobody is perfect"; 2) age = 22; 3) –0.35 4) π = 3.14159265; 5) greeting = "Hello World!"; 6) weather = 42˚; 7) a = 25, b = 23, a = b “True or False”. 8) L1 = 'J'; 9) GPA = 3.67; 10) i = 1000000;

9 9 Exercises Answers Identify the most suitable data type for the followings: 1) String 2) Integer 3) Real Number 4) Real Number 5) String 6) Integer 7) Boolean 8) String 9) Real Number 10) Integer

10 10 Constants and Variables الثوابت والمتغيرات A Constant is a memory location whose value remains the same during the execution of the program. الثابت عبارة عن قيمة ثابته لا تتغير أثناء تنفيذ البرنامج. A Variable is a memory location whose contents can be changed during the execution of the program. المتغير هو عبارة عن قيمة قد تتبدل (تتغير) أثناء تنفيذ البرنامج.

11 Constants and Variables الثوابت والمتغيرات Question: Determine the constants and variables when calculating a commission for a salesman with a percentage of (4%) of sales. حدد الثوابت والمتغيرات في عملية إحتساب عمولة (Commission) مندوب مبيعات في مؤسسة وقيمتها (Percentage) 4% من قيمة المبيعات (Sales). Answer: Constant is the percentage = 4%. Variables are the sales and commissions. 11

12 Constants and Variables الثوابت والمتغيرات Question: University of Jordan has 5000 academic and administrative staff each of which earns a different salary based on his/her rank. Every staff in the university is subject to an income tax, which is 20% per annum. Identify the constants and variables in the above scenario. Answer: Number of staff = 5000 is a constant Income tax = 20% is a constant Salary = x is a variable 12

13 Constants and Variables الثوابت والمتغيرات Question: Identify the constants and the variables in the following quadratic equation. y = 2x 2 + 5x + 10 Answer: Constants: 2, 5, and 10 Variables: x and y 13

14 Assignment Statements جمل التعيين Assignment statement is used to assign values to the declared variables. لابد من تحديد قيم للمتغيرات التي بدورها ستخزن في مواقع محددة داخل ذاكرة الحاسوب. The general format of the assignment statement is: Variable_Name = Expression Variable_Name is the name of a variable that is previously declared. The left hand side cannot be an expression. لا يجوز أن يكون الطرف الأيسر تعبيراً أو ثابتاً، وإنما يجب أن يكون متغيراً وحيداً فقط. 14

15 Assignment Statements جمل التعيين Expression can be a constant, variable, logical, arithmetic or string of characters. الطرف الأيمن من جملة التعيين يمكن أن يكون ثابتاً أو متغيراً آخر معرفاً في جملة سابقة، أو سلسلة حروف أو تعبيراً رياضياً أو منطقياً. Important Note: The left and right hand sides of the assignment statement must be of the same data type. لابد أن يكون هنالك توافق ما بين الطرف الأيمن والطرف الأيسر في جملة التعيين (حول إشارة المساواة =). أي أن يكون ناتج الطرف الأيمن من نوع البيانات نفسه للمتغير في الطرف الأيسر. 15

16 Assignment Statements جمل التعيين Examples: 1) X = 6;  This assignment statement assigns the value 6 to the variable X. 2) S = X + 10;  This assignment statement assigns the value of the expression X + 10 to the variable S.  This implies that the value of the expression will be evaluated first. Increment and decrement of variables:  Increment the variable X by 5, X+=5, OR X = X + 5;  Decrement the variable X by 2, X – =2, OR X = X – 2; 16

17 Arithmetic, Logical, and Relational Operations العمليات الحسابية والمنطقية والعلائقية هنالك مجموعة من العمليات الحسابية والمنطقية والعلائقية تستخدم في أي تعبير رياضي أو منطقي. The arithmetic operations (العمليات الحسابية) are: 17 العملية Operation رمز العملية Operation Code Addition الجمع + Subtraction الطرح - Multiplication الضرب * Division القسمة / Modulus المعامل المطلق Mod Exponentiation المعامل الأسي ^

18 Arithmetic, Logical, and Relational Operations العمليات الحسابية والمنطقية والعلائقية Important Notes: بالنسبة لعملية القسمة فالمطلوب هو القسمة الحقيقية. بالنسبة لعملية إيجاد الباقي (Mod) فالتركيز فقط على الأعداد الصحيحة الموجبة فقط. Examples: Calculate Mod of 5 when x = 17  Mod 5 = 2 Calculate Mod of 17 when x = 5  Mod 17 = 5  السبب: إذا كان المقسوم علية أكبر من القاسم فتكون الإجابة هي قيمة القاسم. 18

19 Arithmetic, Logical, and Relational Operations العمليات الحسابية والمنطقية والعلائقية هنالك أيضا مجموعة من العمليات المنطقية تستطيع إستخدامها في برنامجك. The logical operations (العمليات المنطقية) are:  AND  OR  NOT تستخدم هذه العمليات في تكوين تعبير منطقي، وقيمة التعبير المنطقي تحتمل الإجابة الصحيحة (True) أو الإجابة الخاطئة (False). 19

20 Arithmetic, Logical, and Relational Operations العمليات الحسابية والمنطقية والعلائقية النتائج المنطقية عند إستخدام AND 20 ABA AND B True False TrueFalse

21 Arithmetic, Logical, and Relational Operations العمليات الحسابية والمنطقية والعلائقية النتائج المنطقية عند إستخدام OR 21 ABA OR B True FalseTrue FalseTrue False

22 Arithmetic, Logical, and Relational Operations العمليات الحسابية والمنطقية والعلائقية النتائج المنطقية عند إستخدام NOT 22 ANOT A TrueFalse True

23 Arithmetic, Logical, and Relational Operations العمليات الحسابية والمنطقية والعلائقية هنالك نوع آخر من العمليات تسمى بالعمليات العلائقية (Relational) أو معاملات المقارنة. The relational operations (العمليات العلائقية) are: 23 العملية Operation الرمز Symbol Greater than أكبر من > Less than أقل من < Greater than or equal أكبر من أو تساوي >= Less than or equal أقل من أو تساوي <= Equal المساواة = Not Equal لا تساوي

24 Arithmetic, Logical, and Relational Operations العمليات الحسابية والمنطقية والعلائقية Such operations are used for comparison, and the result is of a logical type (True/False). هذه العمليات تحتمل الإجابة الصحيحة (True) أو الإجابة الخاطئة (False). ولكن كيف يقوم الحاسوب بحساب التعابير المختلفة ويحد لها قيمة محتملة واحدة؟  إن الحاسوب يعتمد على قاعدة أساسية للتطبيق وهي أولوية تنفيذ العمليات، وينفذ أي تعبير حسب القواعد والأولويات التالية:  يقوم بإجراء العمليات من اليسار إلى اليمين  في حالة وجود أقواس يبدأ أولاً بالأقواس من اليسار إلى اليمين، وعندما تكون هنالك أقواس متداخلة، يبدأ بالأقواس الداخلية ومن ثم ينتقل بإتجاه الأقواس التالية خارجياً.  يتم تنفيذ العمليات من اليسار إلى اليمين حسب الأولويات التالية: (يتبع <----) 24

25 Arithmetic, Logical, and Relational Operations العمليات الحسابية والمنطقية والعلائقية Operations in an expression are performed according to the following priorities (orders): 25 الرمز Symbol العملية Operation الأولوية Priority ( )Parenthesis الأقواس 1. Arithmetic ^Exponentiation رفع القوى 2. *, / Multiplication الضرب 3. Division القسمة ModModulus المعامل المطلق 4. +, - Addition الجمع 5. Subtraction الطرح Relational>, =, Comparison المقارنة 6. Logical NOT AND OR Logical المنطقية 7.

26 26 Exercises Example 1: (Refer to Page 7) Solve the following equation: A = 2 * 3 + 6 * 3 – (4 + 2) * 2 Example 2: (Refer to Pages 7 – 8) Assume that a = 1, b = 2, c = 3, and d = 2 are given, what does each of the following expressions produce?  (d <= 99 AND c < d)  (b >= a OR c = d)  (c + d = c)

27 27 Exercises Example 3: (Refer to Page 8) Assume that A = 50, B = 70, C = 80, and D = 90 are given, what does each of the following expressions produce?  V1 = (A > B) AND (B < C)  V2 = (A B) AND (B C)  V3 = (A A)  V4 = V1 AND (V2 OR V3) OR (A < C)

28 28 Additional Exercises Solve the following equations: 1) Y = 6 * 3 – (4 + 2) * 2 + 10 MOD 3 ^ 1 ^ 2 – 8 2) X = 3.6 + 9 MOD (6 * (3 + 2)) / 2 + 2 ^ (3 – 2) * 2 3) X = 1 and Y = 5 Z = X Y OR X + 2 < (X + Y) / 2 4) Y = 3 >= 9 OR (5+1) 2 AND NOT ((7 – 3) < 2 OR FALSE)

29 29 Problem Solving حل المسائل The basic flow of computer processing is input, process, and output. This is done through programming.  Refer to Figure (1 – 1). يقوم الحاسوب بإدخال البيانات ومعالجتها وإخراج النتائج بشكل معلومات عن طريق كتابة البرنامج وإدخالها للحاسوب. Input Output Process

30 30 Problem Solving حل المسائل Computer program is a set of instructions that tell the computer how to process data. البرنامج عبارة عن مجموعة من الأوامر والتعليمات تخبر الحاسوب كيف سيقوم بمعالجة البيانات.

31 31 Problem Solving حل المسائل Example: How would be the input, process, and output to calculate a semester grade average? Input:  Student’s grades from all the courses in the semester. Process:  Adding up the grades and dividing them by the number of courses. Output:  The semester grade average

32 32 Problem Solving حل المسائل To solve a problem, do the following: 1) Analyze (فهم وتحليل المسألة)  This requires the following:  Problem understanding فهم المسألة (المشكلة)  Knowing what the inputs to the problem are تحديد المدخلات  Determining the desired outputs تحديد المخرجات  Knowing what the necessary processing steps to the solution are إتباع الخطوات المطلوبة للحصول على المخرجات المرغوبة

33 33 Problem Solving حل المسائل To solve a problem, do the following: 2) Design a solution تصميم الحل  Developing a set of steps that, when applied, will lead to the best solution using flowcharts or (and) pseudo codes.  تحدد في هذه الخطوة الخطوات المقترحة للحصول على المخرجات المطلوبة، وإختيار أفضل إقتراح للحل. وفي هذه الخطوة أيضا نستخدم مخططات سير العمليات و / أو أشباه العمليات.

34 34 Problem Solving حل المسائل To solve a problem, do the following: 3) Coding the program كتابة البرنامج  This is done using a programming language.  تتم بإستخدام إحدى لغات البرمجة وأشباه اللغات لتسهيل الحل وكتابة البرنامج. 4) Test the program فحص وتدقيق البرنامج  Each part of the program must be tested to make sure that the program is free of errors.  التأكد من عدم وجود أخطاء برمجية في البرنامج.

35 35 Problem Solving حل المسائل To solve a problem, do the following: 5) Validate the solution تقييم الحل  The program should be validated by extensive testing.  التأكد من أن البرنامج يعمل على مجموعة من البيانات المختلفة بشكل سليم.

36 36 Pseudo Codes أشباه البرامج Pseudo code is a set of English-like statements used to help in solving problems. شبه البرنامج هو مجموعة من الجمل (أوامر وتعليمات) لخطوات حل المسألة بلغة قريبة إلى لغة الإنسان. Example: Write a pseudo code to calculate and print a student’s semester grade average for five scores. 1. Get scores for 5 courses 2. Add (sum) the scores together 3. Divide the sum by 5 (number of courses) 4. Print the results (Average)

37 37 Flowcharts مخططات سير العمليات Flowcharts are used to express the flow of data and processing. A flowchart is a structure graph which shows the steps of the algorithm. مخطط سير العمليات عبارة عن مجموعة من الرسومات التوضيحية لخطوات حل المسائل وبيان تدفق البيانات. يساعد هذا المخطط على إكتشاف الأخطاء المنطقية في حل المسألة.

38 38 Flowcharts مخططات سير العمليات

39 39 Flowchart Constructs تراكيب المخططات Regardless of how you represent your solution, you will quickly find that no matter how complicated your solution is, when you simplify it, it is made up of only three very simply constructs. يمكن أن تتجزأ المسألة في المخططات لتتكون من تركيبة أو أكثر. The three constructs are:  Sequence التركيبة المتتالية  Selection التركيبة الإختيارية  Iteration (Looping) التركيبة التكرارية (الدورانية)

40 40 Flowchart Constructs تراكيب المخططات Sequence التركيبة المتتالية A sequence, as the name indicates, means to perform one step at a time, and follow it by the next step, and so on so forth. Refer to Figure (1 – 2). التركيبة المتتالية تمثل سرداً للتعليمات واحدة تلو الأخرى.

41 41 Flowchart Constructs تراكيب المخططات Sequence التركيبة المتتالية Example 1: Draw the flowchart and write a pseudo code to determine the Celsius equivalent for a Fahrenheit temperature. The formula to calculate Celsius is: Celsius = 5 * (Fahrenheit – 32) / 9 Pseudo code 1:  INPUT Fahrenheit Temperature  CALCULATE Celsius Temperature  OUTPUT Celsius Temperature

42 42 Flowchart Constructs تراكيب المخططات Sequence التركيبة المتتالية Example 1: Pseudo code 2:  BEGIN  INPUT Fahrenheit  SUBTRACT 32 from Fahrenheit  MULTIPLY difference by 5  DIVIDE quotient by 9  OUTPUT Celsius  END

43 43 Flowchart Constructs تراكيب المخططات Sequence التركيبة المتتالية Example 1: Flowchart:

44 44 Flowchart Constructs تراكيب المخططات Sequence التركيبة المتتالية Example 2: Draw the flowchart to solve the following equation: X = A * B – C / 5 Flowchart:

45 45 Flowchart Constructs تراكيب المخططات Selection التركيبة الإختيارية A selection means to perform an action only if a condition is true. Refer to Figure (1 – 5). التركيبة الإختيارية تقوم بتنفيذ التعليمات عند تحقيق شرط. Syntax تركيب الجملة If Condition then  Statement (A) Else  Statement (B) End if

46 46 Flowchart Constructs تراكيب المخططات Selection التركيبة الإختيارية

47 47 Flowchart Constructs تراكيب المخططات Selection التركيبة الإختيارية Example: Draw a flowchart to calculate the function f(X) such as: X + 5, X < 50 f(X) = X + 3, Otherwise Pseudo code:  Input X  If X < 50 then F = X + 5  Else  F = X + 3  End if  Print F

48 48 Flowchart Constructs تراكيب المخططات Selection التركيبة الإختيارية Example: Flowchart:

49 49 Flowchart Constructs تراكيب المخططات Iteration or Loopingالتركيبة التكرارية (الدورانية) Iteration or looping means to perform an action as long as a condition is true as shown in Figure (1 – 7), or false as shown in Figure (1 – 8). التركيبة التكرارية (الدورانية) تقوم بتنفذ التعليمات مادام الشرط متحققاً كما في الشكل (1 – 7) أو غير متحقق كما يوضح الشكل (1 – 8). Each time we perform the action, it is known as iteration.

50 50 Flowchart Constructs تراكيب المخططات Iteration or Loopingالتركيبة التكرارية (الدورانية) Note that if the condition tested in the decision is not changed in the True branch, the possibility for an endless loop exists. إذا بقي الشرط متحققا كما في الشكل (1 – 7) فسندخل في تركيبة دورانية غير منتهية، كذلك الأمر بالنسبة للشكل (1 – 8) إذا لم يتحقق الشرط فسندخل في تركيبة دورانية غير منتهية.

51 51 Flowchart Constructs تراكيب المخططات Iteration (Looping) التركيبة التكرارية (الدورانية)  Refer to Figure (1 – 7)

52 52 Flowchart Constructs تراكيب المخططات Iteration (Looping) التركيبة التكرارية (الدورانية)  Refer to Figure (1 – 8)

53 53 Exercises Example 1: What is the output for the following flowchart?  3 4 3  3 3 4  Finish 33

54 54 Exercises Example 2: What is the output for the following flowchart? Assume the inputs are:  10, 3, and 4 Choices:  4 10 3 5  7 7 10 3 8  7 7  None of them

55 55 References مهارات الحاسوب 2 /Computer Skill 2 ، الدكتور "محمد بلال" الزعبي،الدكتور احمد الشرايعة، الدكتور أمجد هديب،خالدة محمد الزعبي, 2012 /الطبعة الأولى


Download ppt "Module 1 Problem Solving حل المسائل 1942102 Computer Skills for Humanities Lecturer: Dr. Mohammad Abd-Alrahman Mahmoud Abushariah"

Similar presentations


Ads by Google