Full Transcript

CC 103 NOTES We can also arranged IPO into: When outputs can be the second Proffesor: Marian Minneli Cruz input of a process. Unit 1: Introduction to Programming Lesson 1: Basic Programming Conce...

CC 103 NOTES We can also arranged IPO into: When outputs can be the second Proffesor: Marian Minneli Cruz input of a process. Unit 1: Introduction to Programming Lesson 1: Basic Programming Concepts What is Programming? - It is a process which involves planning, scheduling, or performing of a task or an event. - Has a Logical Sequence When data could be greater than (>), (Pagkasunod-sunod). Equal to (=), or less than (=75) then print “passed” else print “failed” Flowchart Selection/Conditional - The execution of instructions by selection, wherein conditions for a series of alternative statements are evaluated to specify which instructions is to be executed. In Problem 5: Compute the bonus of an Flowchart: employee. Consider the following criteria: If the employee’s salary is greater than or equal to 10,000 pesos, the bonus is 50% of the salary; else, the bonus is 25% of the salary. Salary is hours worked time rate per hour. Algorithm: Let h= hours worked ; r= rate per hour; b= bonus; s=salary Repetition/Iteration/Loop - Allows a set of instructions to be repeated or carried out several times until certain conditions have been meet. Two Types of Repetition/Ilteration/Loop 1. Count-Controlled Loop How it works: the loop holds a count of the number of times it runs, and the loop stops Flowchart: when the count reaches the specified count. Problem 6: Compute the bonus of an This loop normall performs the employee. Consider the following criteria: following: If the employee’s salary is less than 10,000 Initialization - the control variable pesos the bonus is 25% of the salary; for (counter) is initialized to the starting employees with salaries greater than to value before the loop starts 10,000 pesos, the bonus is 50% of the Test - the loop terminating salary; and for salaries equal to 10,000 condition that checks if looping pesos, bonus is 35% of salary. Salary is should continue hours worked times rate per hour Increment (or decrement) - value of which the control variable is Algorithm: modified each iteration of the loop. Let h=hours worked ; r=rate per hour ; b=bonus; s=salary Problem 7: Create a flowchart that accepts Flowchart number 5 times. 2. Condition-Controlled Loop - Is used when it is not known how many times iteration will need to occur. Flowchart Problem 8: Create a flowchart that accepts numbers and stops when the user enters 0. Free Response: *ps kayo magsasagot dito, para mapractice tayo* Modular/Procedural component of Sun Microsystems’ Java platform. - This approach is sometimes called - The Language derives much of its “divide and conquer” because a syntax from C and C++ but has a large task is divided into several simpler object model and fewer smaller tasks that are easily low-level facilities. performed. Application - It is a regular program meant to be run on your computer Flowchart Applet - It is a little program meant to be run on the internet. - They are programs that are embedded in other applications, typically in a Web page displayed on the Web browser. Compiling the program - Use a Just-in-Time (JIT) compiler to translate the Java program into byte-code. Running the Program - Use the bytecode interpreter to translate each bytecode instruction to machine language and to run the machine language instruction Java Byte-Code Unit 2: Java Basics - It is a machine language for a Lesson 1: Overview of Java Language hypothetical computer called “Java Virtual Machine (JVM)”. Java Programming Language - It is a kind of object code generated by a Java compiler and interpreted - It is an objected-oriented by a Java Virtual Machine. programming language originally - Platform independent developed by Sun Microsystems and released in 1995 as a core class static Interpreter void String - It is used to translate byte-code to int machine language. *Yet to be discussed* Identifiers - Technical terms for a name in a Unit 2: Java Basics programming language - Includes the name, variable, name Lesson 2: Basic Elements of a Java of a class, a method or an object Program Symbols Rules of Identifiers Valid name symbols are the capital (,) - Commas are used to separate items in letters. a list A through Z, the lowercase letter a through (;) - Semicolons are used to end statement z. ( +, -, *, /) - Mathematical symbols The digits through 0 through 9 and (=) - Relational operators the underscore The first character of the identifier // single-line comment symbol cannot be a digit or an underscore. For example: Example: //This is my first program //Pogi talaga ni Jd Valid Invalid grade grade+3 multiple-line comment symbol area1 1area For example: area_of_triangle area of triangle Data Type - Defines a set of values that a variable can hold. Reserved Words (Keywords) - Based on the data type, the OS - These words have a special allocates memory and decides what predefined meaning and cannot can be stored in the reserved be used as the names of classes memory. or objects or anything else and used by Java Language for unique purpose. Type Keyword Data Type Boolean boolean true, false Example: public variable = expression; Character char ‘A’, ‘b’, ‘+’ y = 5; Integer int 10, 200, 550 Arithmetic Operator Floating float 10.54, 2.56 Point Operator Meaning Example Double double 10.54, 2.56 * Multiplication x*y Floating Point / Division x/y Valueless void % Modulus x%y + Addition x+y Variable - Subtraction x-y - Can hold a number or data of other types. ++ Increment x++ - Any number or other type of data held in a variable is called “value” -- Decrement x– - In programming languages, + (unary) Positive Sign +x variables are implemented as memory location. - (unary) Negative Sign -x - The compiler assigns a memory location to each variable name Compound Assignment / Arithmetic (identifier) in the program. - Each variable in a program must be Operators: declared. Example: += , -= , *= , /= , %= Variable Declaration y=y+5 = y +=5 A syntax rule to declare a variable is: Datatype identifier; Order of Precedence For Example: - It’s possible to build mathematical int x; expressions with several operations. Operator - When more than one arithmetic operator is used in an expression, - A symbol that tells the compiler to C++ uses the operator precedence perform specific mathematical or rules to evaluate the expression. logical manipulations. * , / , % are higher precedence than +, - Types Assignment Operator - When operations have the same - (=) - is used in the assignment level, the operations are performed statement which takes the following from left to right form: Relational Operator - Two expressions can be compared using relational and equality operators. The result may be true or false. < , > , = , == , =! Logical Operator Example: && (AND) II (OR) ! (NOT) Arithmetic Expression - Is any expression that is used for computations/ mathematical manipulations Boolean Expression - Any expression that is either true or false.

Use Quizgecko on...
Browser
Browser