Pemrograman Komputer Pertemuan 03 Representing Data Bambang Heru Iswanto, Dr.rer.nat M.Si <ul><li>Jurusan Fisika </li></ul...
Learning Outcomes <ul><li>Pada akhir pertemuan ini, diharapkan mahasiswa  </li></ul><ul><li>akan mampu : </li></ul><ul><li...
Learning Outcomes <ul><li>Pada akhir pertemuan ini, diharapkan mahasiswa  </li></ul><ul><li>akan mampu : </li></ul><ul><li...
Outline Materi <ul><li>Data Categorization </li></ul><ul><li>Constants </li></ul><ul><li>Variables </li></ul>01/02/11 ©  2...
Data Categorization <ul><li>Two broad categories of data are numeric and string. </li></ul><ul><ul><li>Numeric data must c...
Constants <ul><li>Data item whose value is assigned at design time and remains the same at run time. </li></ul><ul><li>A l...
Literal Constans <ul><li>Writing Numeric Literal Constants </li></ul><ul><ul><li>Ex. 3.45  +231  .1  9.4E+7 </li></ul></ul...
Literal Constans <ul><li>Run Time: How the Computer Uses Symbolic Constants </li></ul><ul><ul><li>Stored in a reference ta...
Data Types ©  2010 Universitas Negeri Jakarta  |  www.unj.ac.id  | Data type Description Range Byte 1-byte binary data 0 t...
Declaring Variables <ul><li>A variable declaration statement. </li></ul><ul><ul><li>Examples: </li></ul></ul><ul><ul><ul><...
Variable Scope <ul><li>The domain within which a variable can be accessed. </li></ul><ul><li>Set of all the code that can ...
Variable Scope <ul><li>Block and Procedure Level Scope: </li></ul><ul><ul><li>Any variable declared inside a procedure has...
Variable Scope <ul><li>Global Variable: </li></ul><ul><ul><li>Variables that can be shared across all forms have  global s...
Project Structure <ul><li>Project </li></ul><ul><ul><li>Forms </li></ul></ul><ul><ul><ul><li>General Declarations Section ...
Variable Naming Convention <ul><li>Must begin with a letter  </li></ul><ul><li>Cannot have a period (remember that we use ...
TERIMA KASIH 01/02/11 ©  2010 Universitas Negeri Jakarta  |  www.unj.ac.id  |
Upcoming SlideShare
Loading in …5
×

Pemrograman komputer 3 (representasi data)

1,316 views

Published on

unj fmipa-fisika

Published in: Education
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,316
On SlideShare
0
From Embeds
0
Number of Embeds
9
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Pemrograman komputer 3 (representasi data)

  1. 1. Pemrograman Komputer Pertemuan 03 Representing Data Bambang Heru Iswanto, Dr.rer.nat M.Si <ul><li>Jurusan Fisika </li></ul><ul><li>Fakultas Matematika dan Ilmu Pengetahuan Alam </li></ul>01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  2. 2. Learning Outcomes <ul><li>Pada akhir pertemuan ini, diharapkan mahasiswa </li></ul><ul><li>akan mampu : </li></ul><ul><li>Menerapkan prinsip – prinsip dasar algoritma menggunakan pseudo code dan flowchart </li></ul>01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  3. 3. Learning Outcomes <ul><li>Pada akhir pertemuan ini, diharapkan mahasiswa </li></ul><ul><li>akan mampu : </li></ul><ul><li>Menunjukkan representasi data, konstanta dan variabel </li></ul>01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  4. 4. Outline Materi <ul><li>Data Categorization </li></ul><ul><li>Constants </li></ul><ul><li>Variables </li></ul>01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  5. 5. Data Categorization <ul><li>Two broad categories of data are numeric and string. </li></ul><ul><ul><li>Numeric data must contain only numbers. </li></ul></ul><ul><ul><li>String data can contain any symbol. </li></ul></ul><ul><ul><li>Numeric data is used in arithmetic calculations. </li></ul></ul><ul><ul><li>String data cannot be used in calculations. </li></ul></ul>01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  6. 6. Constants <ul><li>Data item whose value is assigned at design time and remains the same at run time. </li></ul><ul><li>A literal constant is just a value. </li></ul><ul><li>A symbolic constant is a descriptive name substituted for a literal constant. </li></ul><ul><li>Four different kinds of constants: </li></ul><ul><ul><li>Numeric literal. </li></ul></ul><ul><ul><li>String literal. </li></ul></ul><ul><ul><li>Numeric symbolic. </li></ul></ul><ul><ul><li>String symbolic. </li></ul></ul>01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  7. 7. Literal Constans <ul><li>Writing Numeric Literal Constants </li></ul><ul><ul><li>Ex. 3.45 +231 .1 9.4E+7 </li></ul></ul><ul><li>Writing String Literal Constants </li></ul><ul><ul><li>Ex. “Hello Jean” </li></ul></ul><ul><li>Symbolic Constants </li></ul><ul><ul><li>INTERESTRATE represents 0.045. </li></ul></ul><ul><li>Creating/Choosing Symbolic Constant Names </li></ul><ul><ul><li>Names are chosen by the developer. </li></ul></ul><ul><ul><li>Naming rules must be adhered to. </li></ul></ul><ul><li>The Constant Definition Statement </li></ul><ul><ul><li>Ex. Const INTERESTRATE = 0.045 </li></ul></ul>01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  8. 8. Literal Constans <ul><li>Run Time: How the Computer Uses Symbolic Constants </li></ul><ul><ul><li>Stored in a reference table for later use. </li></ul></ul><ul><li>Advantages of Using Symbolic Constants </li></ul><ul><ul><li>Make program easier to understand. </li></ul></ul><ul><ul><li>Reduce the chance of program inconsistencies. </li></ul></ul><ul><li>Literal versus Symbolic Constants </li></ul><ul><ul><li>The null string (“”) and numeric data used in formulas should be the only literal constants. </li></ul></ul><ul><li>Typical Uses of Symbolic Constants </li></ul><ul><ul><li>Prime interest rate. </li></ul></ul><ul><ul><li>Overtime rate. </li></ul></ul><ul><ul><li>Number of print lines for a printed page. </li></ul></ul><ul><li>Predefined Symbolic Constants </li></ul><ul><ul><li>Visual Basic contains a large set. </li></ul></ul><ul><ul><li>Contained in classes, such as the Math and Color classes. </li></ul></ul>01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  9. 9. Data Types © 2010 Universitas Negeri Jakarta | www.unj.ac.id | Data type Description Range Byte 1-byte binary data 0 to 255 Integer 2-byte integer – 32,768 to 32,767 Long 4-byte integer – 2,147,483,648 to 2,147,483,647 Single 4-byte floating-point number – 3.402823E38 to – 1.401298E – 45 (negative values) 1.401298E – 45 to 3.402823E38 (positive values) Double 8-byte floating-point number – 1.79769313486231E308 to – 4.94065645841247E – 324 (negative values) 4.94065645841247E – 324 to 1.79769313486231E308 (positive values) Currency 8-byte number with fixed decimal point – 922,337,203,685,477.5808 to 922,337,203,685,477.5807 String String of characters Zero to approximately two billion characters Variant Date/time, floating-point number, integer, string, or object. 16 bytes, plus 1 byte for each character if a string value. Date values: January 1, 100 to December 31, 9999 Numeric values: same range as Double String values: same range as String Can also contain Error or Null values Boolean 2 bytes True or False Date 8-byte date/time value January 1, 100 to December 31, 9999 Object 4 bytes Any Object reference
  10. 10. Declaring Variables <ul><li>A variable declaration statement. </li></ul><ul><ul><li>Examples: </li></ul></ul><ul><ul><ul><li>Dim StreetAddress As String </li></ul></ul></ul><ul><ul><ul><li>Dim GrossWeight As Integer </li></ul></ul></ul><ul><ul><ul><li>Dim HomePhone As String </li></ul></ul></ul><ul><ul><ul><li>Dim NetIncome As Decimal </li></ul></ul></ul><ul><ul><ul><li>Dim CurrentStudent As Boolean </li></ul></ul></ul><ul><li>Syntax of the Assignment Statement </li></ul><ul><ul><li>variablename = expression </li></ul></ul><ul><ul><ul><li>Ex. CourseCode = “CISB119” </li></ul></ul></ul><ul><li>Run Time: The Effect of the Assignment Statement </li></ul><ul><ul><li>Evaluates expression on right side of equal sign. </li></ul></ul><ul><ul><li>Stores value of expression in variable on left side of equal sign. </li></ul></ul><ul><li>Changing Variable Values during Execution </li></ul><ul><ul><li>Storing a value in a variable will overwrite any existing value. </li></ul></ul><ul><li>Control Properties in Assignment Statements </li></ul><ul><ul><li>Ex. lblHomePrice.Text = 210000 </li></ul></ul><ul><li>Why Use Variables </li></ul><ul><ul><li>Ideal to store results of intermediate calculations. </li></ul></ul><ul><ul><li>Values stored in variables may be retrieved and formatted. </li></ul></ul>01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  11. 11. Variable Scope <ul><li>The domain within which a variable can be accessed. </li></ul><ul><li>Set of all the code that can refer to a variable. </li></ul><ul><li>Determined by where and how the variable is declared. </li></ul><ul><li>There are four levels: block, procedure (local), module, and global. </li></ul>01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  12. 12. Variable Scope <ul><li>Block and Procedure Level Scope: </li></ul><ul><ul><li>Any variable declared inside a procedure has procedure-level scope. </li></ul></ul><ul><ul><li>Variable can only be accessed by statements in that procedure. </li></ul></ul><ul><ul><li>Scope can be narrowed to a single block of code within the procedure. </li></ul></ul><ul><li>Module Level Variables: </li></ul><ul><ul><li>Any variable declared inside a procedure has procedure-level scope. </li></ul></ul><ul><ul><li>Variable can only be accessed by statements in that procedure. </li></ul></ul><ul><ul><li>Scope can be narrowed to a single block of code within the procedure. </li></ul></ul>01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  13. 13. Variable Scope <ul><li>Global Variable: </li></ul><ul><ul><li>Variables that can be shared across all forms have global scope . </li></ul></ul><ul><ul><li>The Public Statement </li></ul></ul><ul><ul><ul><li>Used to create a global variable. </li></ul></ul></ul><ul><ul><li>Modules </li></ul></ul><ul><ul><ul><li>Repository for data that need to be shared by forms. </li></ul></ul></ul><ul><ul><ul><li>Repository for global variables. </li></ul></ul></ul><ul><ul><li>Hiding Global Variables </li></ul></ul><ul><ul><ul><li>A procedure-level variable in a procedure “hides” a global variable with the same name. </li></ul></ul></ul><ul><ul><ul><li>A module-level variable will “hides” a global variable with the same name. </li></ul></ul></ul><ul><ul><li>Procedure-Level, Module-Level, and Global Scope </li></ul></ul><ul><ul><ul><li>A procedure-level variable is declared in a procedure using a Dim statement. </li></ul></ul></ul><ul><ul><ul><li>A module-level variable is declared in the declarations section of a form using a Dim statement. </li></ul></ul></ul><ul><ul><ul><li>A global variable is declared in the declarations section of a module using the Public statement. </li></ul></ul></ul>01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  14. 14. Project Structure <ul><li>Project </li></ul><ul><ul><li>Forms </li></ul></ul><ul><ul><ul><li>General Declarations Section </li></ul></ul></ul><ul><ul><ul><li>Controls </li></ul></ul></ul><ul><ul><ul><ul><li>Properties </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Event Procedures </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Methods </li></ul></ul></ul></ul><ul><ul><li>Code Modules </li></ul></ul><ul><ul><ul><li>General Declarations Section </li></ul></ul></ul>01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  15. 15. Variable Naming Convention <ul><li>Must begin with a letter </li></ul><ul><li>Cannot have a period (remember that we use the period to set a property; in other words the period is an operator) </li></ul><ul><li>Can have up to 255 characters. Please, just because it is allowed, don't use 255 characters. </li></ul><ul><li>Must be unique inside of the procedure or the module it is used in </li></ul><ul><li>Must not be a VB keyword. </li></ul>01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  16. 16. TERIMA KASIH 01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |

×