User defined procedures and functions presentation 1 variant
Оценка 4.8

User defined procedures and functions presentation 1 variant

Оценка 4.8
pptx
02.05.2020
User defined procedures and functions  presentation  1 variant
User defined procedures and functions presentation 1 variant.pptx

User defined procedures and functions

User defined procedures and functions

User defined procedures and functions

Algorithmization and Programming

LEARNING OBJECTIVES write a code in the programming language using functions and procedures

LEARNING OBJECTIVES write a code in the programming language using functions and procedures

LEARNING OBJECTIVES

write a code in the programming language using functions and procedures

The concepts of functions and methods

The concepts of functions and methods

The concepts of functions and methods

A function is a part of a program that has its own name.
This name can be used in the program as a command (this command is called a function call).
When a function is called, the commands of which it consists are executed. A function call can return a value (similar to an operation) and therefore can be used in an expression along with operations.
A method is a function that is part of a class that can perform operations on data of this class. In the Java language, the entire program consists only of classes and functions can be described only inside them. That is why all functions in the Java language are methods.

Concept of method Methods are always defined inside classes: minOfTwoNumbers is the method we defined in the

Concept of method Methods are always defined inside classes: minOfTwoNumbers is the method we defined in the

Concept of method

Methods are always defined inside classes:


minOfTwoNumbers is the method we defined in the Main class, let's consider it.
public - access type (the method can be called from another class). There are other types of access, for example private (the method is available only inside the class) and protected.
static - means that the method is static, it belongs to the class Main, and not to a specific instance of the class Main. We can call this method from another class like this: Main.minOfTwoNumbers ().

Parsing code public class { public static (type parameter1, type parameter2) { } public static void main(String[] args) { //

Parsing code public class { public static (type parameter1, type parameter2) { } public static void main(String[] args) { //

Parsing code

public class {
public static (type parameter1, type parameter2) {
}
public static void main(String[] args) {
// Your software code is here
}
}

Parsing code In lines 3 through 11, the minOfTwoNumbers method is described

Parsing code In lines 3 through 11, the minOfTwoNumbers method is described

Parsing code

In lines 3 through 11, the minOfTwoNumbers method is described.
On lines 5-9 performs a comparison of the values of a and b
On line 13, the method is called to determine the minimum of two numbers (4 and -6).

Task Create a method that imposes a maximum of two numbers

Task Create a method that imposes a maximum of two numbers

Task

Create a method that imposes a maximum of two numbers.
System.out.println("max = "+maxOfTwoNumbers(0, -99));


2. Create a method to calculate the 3rd power of the number.
System.out.println("7*7*7 = "+Cube(7));

Homework Create a method that defines even and odd numbers

Homework Create a method that defines even and odd numbers

Homework

Create a method that defines even and odd numbers.
Create a method that determines the area and circumference of the circle.

Reflection Today I learned ...

Reflection Today I learned ...

Reflection

Today I learned ...
It was hard to…
I realized that ...
I learned…
I was able to ...
it was interesting to know that ...
I was surprised ...
I wanted…

Материалы на данной страницы взяты из открытых истончиков либо размещены пользователем в соответствии с договором-офертой сайта. Вы можете сообщить о нарушении.
02.05.2020