I am sharing 'Copy-of-Programming-01-PRELIMINARIES-REVIEWER_20240916_233420_0000' with you.pdf
Document Details
Uploaded by Deleted User
Tags
Full Transcript
if we want to assign value to a variable that is fixed 1.Program documentation contains...
if we want to assign value to a variable that is fixed 1.Program documentation contains information that improves the readability of V A R I A B LES the program. value that can be changed depending on 2.Comments are part of the program conditions or on information passed to the documentation because they help others program can be reused throughout the read and understand how the program works. program, instead of having to type out the The compiler and interpreters, however, actual value all over and over again ignore comments and they are not translated in machine language. VARIABLE DECLARATION TYPES OF COMMENTS IN JAVA In Java Programming, you can define a 1. MULTIPLE LINE COMMENTS - comments variable with the following format: enclosed by /* and /* Data Type Variable Name = Value 2. SINGLE LINE COMMENTS - comments String User_Name = “Juan Dela Cruz” placed after // symbols Always remember that Java is case IDENTIFIERS sensitive programming language similar to IDENTIFIERS - names given to various C languages program elements such as variables, RULES IN USING VARIABLES functions, and arrays A VARIABLE CAN: The following are the guidelines in creating Any unicode character that is a letter identifiers in Java (including numeric letters like Roman 1.Consists of letters and digits without numerals) or a digit space, in any other, except that the first Currency sign (such as $) character must be a letter. Connecting punctuation character (such 2.Uppercase and lowercase are permitted as _) A VARIABLE CANNOT: but they are not interchangeable. As an Variable names are CASE-SENSITIVE. exception, an underscore may be used as A variable’s name can be any legal identifier. the first character of the identifier. It can contain unicode letter, digits, and two 3.Reserved words and standard methods must special characters such as underscore and not be used. $ dollar sign. Example of Valid Identifiers: Length of Variable name can be any Salary_Per_Month _area_cir number. It is necessary to use alphabet at the start (however, we can use underscore). Some auto generated variable may contain ‘$’ sign. But try to not use dollar sign. White space is not permitted. Age PESONS_NAME Special Characters are not allowed. A digit at the start is not allowed. Subsequent characters may be letters, digits, dollar signs, or underscore characters. Variable name must not be a Grade23 Y keyword or reserved word. RULES IN USING VARIABLES variables Example of Invalid Identifiers: whose value does not change during EXAMPLE program execution; useful if we want to assign value to a variable that is fixed Final Data Type Variable Name = Value IMPORTANCE OF COMMENTS ON PROGRAMS COMMENTS - variables whose value does 3RD not change during program execution; useful DATA TYPE specifies possible range of values of the set, the operations that can be performed BIR TAX Contains space used so that the compiler or interpreter of a programming language can be told about the data which is to be used %price Contains special character while A reserved word RESERVED WORDS standard predefined words; not allowed to use as variable names or objects J A V A O P E R A TO R S ARITHMETIC OPERATORS RELATIONAL OPERATORS LOGICAL OPERATORS BITWISE OPERATORS shift the bit value; first (left) operand represents the value to undergo the shift, while the second (right) operand defines the number of positions to shift the buts in the value significance of both operands is equal ASSIGNMENT OPERATORS