Presentación 0 - Programación Básica
-
Upload
thekingartur6 -
Category
Documents
-
view
19 -
download
0
Transcript of Presentación 0 - Programación Básica
![Page 1: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/1.jpg)
Basic programming review
Christian Rodríguez Bustos
Object Oriented Programming
Basic programming review
![Page 2: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/2.jpg)
Basic concepts
Control Structures
Operators Arrays
Agenda
Basic programming review
![Page 3: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/3.jpg)
Algorithm
Flow diagram
Speudo code
Basic concepts
Basic programming review
![Page 4: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/4.jpg)
Any computing problem can be solved by executing a series of actions in a specific order.
An algorithm is a step-by-step procedure
Basic programming review
Finite Deterministic Precision
![Page 5: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/5.jpg)
1. Get out of bed
2. Take off pajamas
3. Take a shower
4. Get dressed
5. Eat breakfast
6. Take the bus
7. Arrive workplace
An algorithm is a step-by-step procedure
Basic programming review
Problem that we want to solve Going to work
![Page 6: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/6.jpg)
Algorithms can be represented in several ways
Basic programming review
Algorithm representation
Pseudo Code
Flow diagram/chart
UML activity diagram
![Page 7: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/7.jpg)
Informal descriptions or languages help programmers to develop algorithms without having to worry about the strict details of a
programming language syntax.
Pseudo codes are informal descriptions of algorithms
Basic programming review
Set grade counter to one While grade counter is less than or equal to ten
Input the next grade Add the grade into the total
Set the class average to the total divided by ten Print the class average.
All pseudo codes should be: • Human readable • Can easily be converted to any
programming language
I am a pseudo code
![Page 8: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/8.jpg)
Flow diagrams are used to represent algorithms
Basic programming review
Begin or End
Process, task, action, or operation
Decision Connector
Input or output
Document
Page connector
Subroutine or function
Resource: What do the different flowchart shapes mean?
Data Storage
Tape
We are used to represent processes flows
![Page 9: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/9.jpg)
These Flow diagram and Pseudo code are equivalent
Basic programming review
![Page 10: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/10.jpg)
Activities
Decisions
Start (split) or end (join) of concurrent activities
The start (initial state) of the workflow
The end (final state).
Activity diagrams describe the workflow of a system
Basic programming review
![Page 11: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/11.jpg)
Activity diagrams describe the workflow of a system
Basic programming review
I am a UML activity diagram
![Page 12: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/12.jpg)
Sequence Structure
Selection Statements
Repetition Statements
Control Structures
![Page 13: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/13.jpg)
Programs are formed by combining as many sequence, selection and repetition statements.
Control Structures
Basic programming review
selection repetition
if while
if…else do…while
switch for
![Page 14: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/14.jpg)
Sequence structure
Basic programming review
An ordered execution of two or more statements are called sequence structure
![Page 15: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/15.jpg)
If student’s grade is greater than or equal to 60
Print “Passed”
IF Selection Statement
Basic programming review
![Page 16: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/16.jpg)
If student’s grade is greater than or equal to 60
Print “Passed”
Else
Print “Failed”
IF..ELSE Selection Statement
Basic programming review
![Page 17: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/17.jpg)
IF..ELSE Selection Statement abbreviated form
Basic programming review
![Page 18: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/18.jpg)
If student’s grade is greater than or equal to 90
Print “A”
else
If student’s grade is greater than or equal to 80
Print “B”
else
If student’s grade is greater than or equal to 70
Print “C”
else
If student’s grade is greater than or equal to 60
Print “D”
else
Print “F”
Nested IF..ELSE Selection Statement
Basic programming review
![Page 19: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/19.jpg)
Indent both body statements of an
if…else statement.
Do not forget…
Basic programming review
1
Always using braces in an if…else (or other) statement helps prevent their accidental
omission
![Page 20: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/20.jpg)
Ugly code is written by ugly people.
Do not be the beast
Basic programming review
I like my code !!
![Page 21: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/21.jpg)
Do not worry, we can format the code automatically
Basic programming review
NetBeans Eclipse
![Page 22: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/22.jpg)
While product is less or equal than 100 products
Multiply by 3 the number of products
WHILE Repetition Statement
Basic programming review
Be careful with infinite loops!!
![Page 23: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/23.jpg)
FOR Repetition Statement
Basic programming review
?????
![Page 24: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/24.jpg)
FOR Repetition Statement
Basic programming review
![Page 25: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/25.jpg)
FOR Repetition Statement
Basic programming review
![Page 26: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/26.jpg)
Vary the control variable from 1 to 100 in increments of 1
Vary the control variable from 100 to 1 in decrements of 1
Vary the control variable from 7 to 77 in increments of 7
Vary the control variable from 20 to 2 in decrements of 2
Vary the control variable over the following sequence of values: ?, ?, ?, ?, ?, ?, ?
Vary the control variable over the following sequence of values: ?, ?, ?, ?, ?,?, ?, ?, ?, ?
FOR Statements header examples
Basic programming review
![Page 27: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/27.jpg)
Vary the control variable from 1 to 100 in increments of 1
Vary the control variable from 100 to 1 in decrements of 1
Vary the control variable from 7 to 77 in increments of 7
Vary the control variable from 20 to 2 in decrements of 2
Vary the control variable over the following sequence of values: 2, 5, 8, 11, 14, 17, 20
Vary the control variable over the following sequence of values: 99, 88, 77, 66, 55,44, 33, 22, 11, 0
FOR Statements header examples
Basic programming review
![Page 28: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/28.jpg)
FOR Statement example
Basic programming review
![Page 29: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/29.jpg)
DO…WHILE Repetition Statement
Basic programming review
Remember always include braces !!!
![Page 30: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/30.jpg)
SWITCH Multiple-Selection Statement
Basic programming review
![Page 31: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/31.jpg)
SWITCH Multiple-Selection Statement
Basic programming review
![Page 32: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/32.jpg)
BREAK and CONTINUE Statements
Basic programming review
Break
Continue
![Page 33: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/33.jpg)
Basic programming review
![Page 34: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/34.jpg)
Summary
Basic programming review
![Page 35: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/35.jpg)
Logical Operators
Assignment Operators
Increment and Decrement Operators
Operators
![Page 36: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/36.jpg)
Conditional AND (&&)
Conditional OR (||)
Logical Negation (!)
Logical Operators
Basic programming review
![Page 37: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/37.jpg)
Logical Operators - Truth tables
Basic programming review
![Page 38: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/38.jpg)
variable = variable operator expression;
Assignment Operators
Basic programming review
![Page 39: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/39.jpg)
Compound Assignment Operators
Basic programming review
![Page 40: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/40.jpg)
Increment and Decrement Operators
Basic programming review
![Page 41: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/41.jpg)
Prefix and Postfix Example
Basic programming review
![Page 42: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/42.jpg)
Java Primitive Types
Basic programming review
![Page 43: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/43.jpg)
Arrays
![Page 44: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/44.jpg)
Container object that holds a fixed number of values of a single type
Arrays are containers
Basic programming review
or
![Page 45: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/45.jpg)
Arrays use example 1
Basic programming review
![Page 46: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/46.jpg)
Arrays use example 2
Basic programming review
? ? ? ? ? ?
![Page 47: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/47.jpg)
Arrays use example 2
Basic programming review
![Page 48: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/48.jpg)
Arrays use example 3
Basic programming review
? ? ? ? ? ?
![Page 49: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/49.jpg)
Arrays use example 3
Basic programming review
![Page 50: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/50.jpg)
Working with multidimensional arrays
Basic programming review
![Page 51: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/51.jpg)
Basic programming review
Method 2 (function)
Multidimensional array use example
Method 1 (function)
![Page 52: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/52.jpg)
Multidimensional array use example
Basic programming review
![Page 53: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/53.jpg)
1. Do the Eclipse HelloWord!! or NetBeans HelloWord!!
2. Modify the “Multidimensional array use example ”code in order to:
– print the main diagonal of the next two multidimensional arrays
Class Exercise
Basic programming review
1 2 3
4 5 6
7 8 9
a b c d
e f g h
i j k l
m n o p
Numbers array
Letters array
![Page 54: Presentación 0 - Programación Básica](https://reader033.fdocuments.in/reader033/viewer/2022051018/55cf96bf550346d0338d840f/html5/thumbnails/54.jpg)
• [Deitel] H.M. Deitel and P.J. Deitel, Java How to Program: Early Objects Version, Prentice Hall, 2009.
• Oracle – Java Lesson: Language Basics
– http://download.oracle.com/javase/tutorial/java/nutsandbolts/index.html
References
Basic programming review