Презентация Data Types and Operators (Java, Lecture 04) онлайн

На нашем сайте вы можете скачать и просмотреть онлайн доклад-презентацию на тему Data Types and Operators (Java, Lecture 04) абсолютно бесплатно. Урок-презентация на эту тему содержит всего 38 слайдов. Все материалы созданы в программе PowerPoint и имеют формат ppt или же pptx. Материалы и темы для презентаций взяты из открытых источников и загружены их авторами, за качество и достоверность информации в них администрация сайта не отвечает, все права принадлежат их создателям. Если вы нашли то, что искали, отблагодарите авторов - поделитесь ссылкой в социальных сетях, а наш сайт добавьте в закладки.
Презентации » Устройства и комплектующие » Data Types and Operators (Java, Lecture 04)



Оцените!
Оцените презентацию от 1 до 5 баллов!
  • Тип файла:
    ppt / pptx (powerpoint)
  • Всего слайдов:
    38 слайдов
  • Для класса:
    1,2,3,4,5,6,7,8,9,10,11
  • Размер файла:
    1.16 MB
  • Просмотров:
    68
  • Скачиваний:
    0
  • Автор:
    неизвестен



Слайды и текст к этой презентации:

№1 слайд
MODULE - Compact Course
Содержание слайда: MODULE 1-05: Compact Course Programming Lesson 4 - Data Types and Operators -

№2 слайд
Content Simple Data Types,
Содержание слайда: Content Simple Data Types, their Values and Operators Expressions Type Conversions

№3 слайд
Try out Answer Overflow and
Содержание слайда: Try out / Answer: Overflow and Precision Go to the following link to check your answer:

№4 слайд
Simple Data Types, their
Содержание слайда: Simple Data Types, their Values and Operators Simple Data Types in Java

№5 слайд
Simple Data Types, their
Содержание слайда: Simple Data Types, their Values and Operators Simple Data Types in Java In difference to some other programming languages, all simple data types in Java have an agreed fixed size in memory For every simple data type a default value is defined, which is of importance with the initialisation of object and class variables (note: local variables are not automatically initialised with the default value)

№6 слайд
Simple Data Types, their
Содержание слайда: Simple Data Types, their Values and Operators Operators Are special symbols that are used to link operands to determine a new value According to their number of operands we can distinguish three types of operators Single digit (monadic oder unary) operators example: the negative sign - Two digit (dyadic oder binary) operators example: the addition sign + Three digit (triadic oder ternary) operatores example: conditional operator ? :

№7 слайд
Simple Data Types, their
Содержание слайда: Simple Data Types, their Values and Operators Logic Values (boolean) Unary Operator (Operator Operand) Operator Description ! logische Negation Binary Operator (Operand1 Operator Operand2) Operator Description Example == Equality false == true  results in false != Inequality false != true  results in true & logic AND | logic OR ^ logic XOR

№8 слайд
Simple Data Types, their
Содержание слайда: Simple Data Types, their Values and Operators Logic Value (boolean) Notation Properties of the Operators (truth table)

№9 слайд
Simple Data Types, their
Содержание слайда: Simple Data Types, their Values and Operators Truth Table (boolean) Boolean Expressions with & and | evaluate both terms completely In practise complete evaluation is often not required & - operation: is one expression false, then the overall result is false | - operation: is one expression true, then the overall result is true The operators && and || ensure a shortened evaluation Example int m = 3; int n = 5; boolean b = (m < 5) || (n > 3); The shortened evaluation is important to reduce the computation time for example with large arrays

№10 слайд
Try out Answer use boolean
Содержание слайда: Try out / Answer: use boolean operators! What is the value of the following expressions? (true & true) | false !!true true & !true (true || false) && true

№11 слайд
Simple Data Types, their
Содержание слайда: Simple Data Types, their Values and Operators Binary Operators (char, byte, short, int, long) Operator Description Example + Addition 5 + 6 yields 11 - Subtraction 9 - 3 yields 6 * Multiplication 10 * 15 yields 150 / Whole Number Division 13 / 3 yields 4 % Modulo (remainder of 20 % 7 yields 6 a whole number division) < smaller 3 < 5 yields true <= smaller equal 3 <= 3 yields true > bigger 2 > 10 yields false >= bigger equal 5 >= 6 yields false == equal 3 == 3 yields true != not equal 5 != 5 yields false

№12 слайд
Try out Answer use boolean
Содержание слайда: Try out / Answer: use boolean operators! What is the value of the following expressions? 7 / 5 7 % 5 5 / 7 5 % 7

№13 слайд
Simple Data Types, their
Содержание слайда: Simple Data Types, their Values and Operators Unary Operators (char, byte, short, int, long) Operator Description Example - Unary Negation -i ++ Increment ++i is the same as i = i+1 -- Decrement --i is the same as i = i-1 Note the difference: Pre-increment vs. Post-increment a = ++b; // is the same as: // b = b+1; a = b; a = b++; // is the same as: // a = b; b = b+1;

№14 слайд
Simple Data Types, their
Содержание слайда: Simple Data Types, their Values and Operators Bitwise - Operators (char, byte, short, int, long) Access to binary representation of whole number data types Numbers are viewed as a set of consecutive bits, which may be manipulated Unary Operator (Operator Operand) Operator Description ~ Complement (bitwise negation) Binary Operators (Operand1 Operator Operand2) Operator Description & bitwise AND | bitwise OR ^ bitwise XOR  The operators >>, >>> and << are used to shift the bits to the right or the left

№15 слайд
Simple Data Types, their
Содержание слайда: Simple Data Types, their Values and Operators Bitwise - Operators (char, byte, short, int, long) Example for shift operator Left-Shift-Operator << int a; a = 10; 00000000 00000000 00000000 00001010 a << 3; 00000000 00000000 00000000 01010000 int a; a = -10; 11111111 11111111 11111111 11110110 a << 3; 11111111 11111111 11111111 10110000  Equivalent to: whole-number multiplication with 23

№16 слайд
Simple Data Types, their
Содержание слайда: Simple Data Types, their Values and Operators Floating-Point-Numbers (float, double) Unary Operators (analog to whole-number types) - ++ -- Binary Operators (analog to whole-number types) + - * / % (arithmetic operators) < <= > >= == != (comparison operators) Note: whole-number division: 45 / 20 Result: 2 floating-point division: 45.0 / 20.0 Result: 2.25

№17 слайд
Simple Data Types, their
Содержание слайда: Simple Data Types, their Values and Operators Floating-Point-Numbers (float, double) Arithmetic Operators Both operands of type float Result type float In all other cases Result type double Attention with equality checks (x == y) // possible rounding errors !

№18 слайд
Simple Data Types, their
Содержание слайда: Simple Data Types, their Values and Operators Composite Operators E1 op= E2 is the same as E1 = E1 op (E2) Example counter = counter + 1; // abbreviated: counter += 1; counter = counter – 1; // abbreviated: counter –= 1; analog: *=, /=, %=, &=, |=, ^=, <<=, >>=, >>>=

№19 слайд
Content Simple Data Types,
Содержание слайда: Content Simple Data Types, their Values and Operators Expressions Type Conversions

№20 слайд
Expressions Expressions
Содержание слайда: Expressions Expressions: Definition and Features Expression: Processing specification, that delivers a value after execution In the simplest case a variable or a constant Through combination of operands, operations and round brackets we get complex expressions Examples radius = 5.5; area = PI * radius * radius; counter = counter + 1;

№21 слайд
Expressions Brackets The
Содержание слайда: Expressions Brackets The evaluation of expressions in brackets always takes place first Just like the rules in mathematics Expressions may be arbitrarily nested Notation of the nested structure is done with round brackets All expressions are provided in linear notation  Expression are provided in line format

№22 слайд
Expressions Example
Содержание слайда: Expressions Example Mathematic format Line format

№23 слайд
Expressions Operator Priority
Содержание слайда: Expressions Operator Priority Rules Well-known from mathematics: „Point before Line“ example 6 + 7 * 3 equals 27 and not 39 In Java: Linking of operators is governed by priorities: An operator with high priority links stronger than an operator with a lower priority If the priority is the same than then the associativity of the operators is evaluated op is is left associative: X op Y op Z equals (X op Y) op Z op ist right associative: X op Y op Z equals X op (Y op Z) Obviously, brackets do control the evaluation order example (6 + 7) * 3 ist 39

№24 слайд
Expressions Priority and
Содержание слайда: Expressions Priority and Associativity

№25 слайд
Expressions Priority and
Содержание слайда: Expressions Priority and Associativity

№26 слайд
Try out Answer use priority
Содержание слайда: Try out / Answer: use priority and associativity! For the following expressions, set brackets such that they yield the same result as the expressions without brackets 1. e = --c - d / a; 2. f = b <= a || c > 16; 3. h = a < 5 || b > 10 && d - c >= 0;

№27 слайд
Expressions Mathematical
Содержание слайда: Expressions Mathematical Constants and Functions The class Math provides important mathematical constants and functions (see online documentation) Constants public static final double E (basis e of nat. logarithm) public static final double PI () Usage: Math.E and Math.PI Methods (Selection) public static double abs(double x) |x| public static double cos(double x) cos(x) public static double sin(double x) sin(x) public static double tan(double x) tan(x) public static double sqrt(double x) √x public static double exp(double x) ex public static double pow(double x, double y) xy Usage: for example result = Math.pow(a,b);

№28 слайд
Definition of Constants
Содержание слайда: Definition of Constants Constants in Java Constants are defined and initialised like variables with the keyword „final“ their names are typically written in capital letters they can not be changed Example: Statement and definition of constants: Statement rewritten with constants: red = Math.min(red + ADDED_RED, MAX_RED)

№29 слайд
Content Simple Data Types,
Содержание слайда: Content Simple Data Types, their Values and Operators Expressions Type Conversions

№30 слайд
Type Conversion Type Conflict
Содержание слайда: Type Conversion Type Conflict Values can only be assigned to variables, if their type is compatible with the type of the variable! Example int a; float b = 10.5f; a = b; // Error because of incompatible types

№31 слайд
Type Conversion Automatic
Содержание слайда: Type Conversion Automatic (implicit) type extension Rules An automatic type extension is happening in the direction of the arrows Example double a, b; float c; a = b + c + 2.785f;

№32 слайд
Type Conversion Type
Содержание слайда: Type Conversion Type extension and selection of operators in expressions Each expression is evaluated step by step according to the priorities and associativity of its operators The operators choosen are the operators that fit to the type of the operands (example: whole number division OR division for floating point numbers) Are the types of operands different, than the „smaller“ operand will receive an automatic type conversion Are both operands of an operation, expressions themselves, then the left operand is calculated before the right operand

№33 слайд
Type Conversion Type
Содержание слайда: Type Conversion Type Extension and Selection of Operators in Expressions Example double a; int b, c; a = 3.0 + 2.785f + b / c; Evaluation: Addition from left to right, point before line a = ((3.0 + 2.785f) + (b / c));

№34 слайд
Type Conversion Explicit Type
Содержание слайда: Type Conversion Explicit Type Conversion: Type Casting Explicit type conversion happens when the desired type is explicitly requested Example int a; float b = 10.25f; a = (int) b; float-value 10.25f is converted in the int-value 10 a = (int)(b / 3.3f + 5.73f); Note: Type casting takes place AFTER the calculation of the entire term b / 3.3f + 5.73f

№35 слайд
Reading Input from the
Содержание слайда: Reading Input from the Console Example code to read an integer and a double from the keyboard:  Remember to import the utilisation class „Scanner“

№36 слайд
Formatted Output Example code
Содержание слайда: Formatted Output Example code to print a number in a specific format:

№37 слайд
Try out Answer Overflow and
Содержание слайда: Try out / Answer: Overflow and Precision Go to the following link to check your answer:

№38 слайд
Homework Assignment Bonus
Содержание слайда: Homework Assignment 04 (2 Bonus Points) (Assignment submission date provided in „Ilias … Homework Assignments“

Скачать все slide презентации Data Types and Operators (Java, Lecture 04) одним архивом: