Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kurs_java_alx_20240321
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
kurs_java_alx_20240321
Commits
4b9913ba
Commit
4b9913ba
authored
Apr 09, 2024
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pierwsze funkcje
parent
1e86bd0a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
0 deletions
+61
-0
EkstremalnieProsteFunkcje.java
src/p09_funkcje/EkstremalnieProsteFunkcje.java
+61
-0
No files found.
src/p09_funkcje/EkstremalnieProsteFunkcje.java
0 → 100644
View file @
4b9913ba
package
p09_funkcje
;
import
java.time.LocalTime
;
public
class
EkstremalnieProsteFunkcje
{
// Funkcja ma wypisać podany tekst tyle razy, ile mówi drugi parametr
static
void
powtorz
(
String
napis
,
int
ileRazy
)
{
for
(
int
i
=
0
;
i
<
ileRazy
;
i
++)
{
System
.
out
.
println
(
napis
);
}
}
// pole prostokąta
static
double
poleProstokata
(
double
a
,
double
b
)
{
return
a
*
b
;
}
// zwraca najmniejszy z trzech podanych argumentów
static
double
min
(
double
x
,
double
y
,
double
z
)
{
if
(
x
<
y
&&
x
<
z
)
{
return
x
;
}
if
(
y
<
z
)
{
return
y
;
}
return
z
;
}
// wyrażenie warunkowe: WARUNEK ? WYNIK1 : WYNIK2
static
double
min2
(
double
x
,
double
y
,
double
z
)
{
return
x
<
y
&&
x
<
z
?
x
:
y
<
z
?
y
:
z
;
}
// zwraca ostatnią cyfrę aktualnej sekundy odczytanej z zegara
static
int
aktualnaSekunda
()
{
return
LocalTime
.
now
().
getSecond
()
%
10
;
}
public
static
void
main
(
String
[]
args
)
{
powtorz
(
"Ala ma kota"
,
5
);
powtorz
(
"Ola ma psa"
,
3
);
System
.
out
.
println
();
double
pole
=
poleProstokata
(
3
,
4
);
System
.
out
.
println
(
"Pole 3×4 = "
+
pole
);
System
.
out
.
println
();
System
.
out
.
println
(
min
(
1
,
2
,
3
));
System
.
out
.
println
(
min
(
3
,
1
,
3
));
System
.
out
.
println
(
min
(
1
,
1
,
1
));
System
.
out
.
println
(
min
(
1
,
3
,
2
));
System
.
out
.
println
(
min2
(
1
,
2
,
3
));
System
.
out
.
println
(
min2
(
3
,
1
,
3
));
System
.
out
.
println
(
min2
(
1
,
1
,
1
));
System
.
out
.
println
(
min2
(
1
,
3
,
2
));
System
.
out
.
println
();
System
.
out
.
println
(
"aktualna sekunda: "
+
aktualnaSekunda
());
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment