Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
2
20231104-KursPodstawowyALX
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
20231104-KursPodstawowyALX
Commits
b8862734
Commit
b8862734
authored
Nov 05, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zgadywanka mnożenia
parent
ca22942c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
0 deletions
+37
-0
Losowanie.java
src/main/java/p04_if/Losowanie.java
+5
-0
Zgadywanka1.java
src/main/java/p04_if/Zgadywanka1.java
+32
-0
No files found.
src/main/java/p04_if/Losowanie.java
View file @
b8862734
...
...
@@ -29,6 +29,11 @@ public class Losowanie {
// Od Java 7
int
r
=
ThreadLocalRandom
.
current
().
nextInt
();
System
.
out
.
println
(
r
);
char
losowaLitera1
=
(
char
)(
65
+
random
.
nextInt
(
26
));
char
losowaLitera2
=
(
char
)(
'A'
+
random
.
nextInt
(
'Z'
-
'A'
+
1
));
System
.
out
.
print
(
losowaLitera1
);
System
.
out
.
print
(
losowaLitera2
);
}
}
src/main/java/p04_if/Zgadywanka1.java
0 → 100644
View file @
b8862734
package
p04_if
;
import
java.util.Random
;
import
java.util.Scanner
;
/* Progam losuje dwie liczby z zakresu od 1 do 10 (później możesz zmienić zakres na większy).
* Program wypisuje te liczby i zadaje pytaje ile wynosi ich iloczyn (wynik mnożenia).
* Użytkownik podaje swoją odpowiedź, a program sprawdza czy jest poprawna, czy nie...
*/
public
class
Zgadywanka1
{
public
static
void
main
(
String
[]
args
)
{
Random
random
=
new
Random
();
int
x
=
random
.
nextInt
(
10
)
+
1
;
int
y
=
random
.
nextInt
(
10
)
+
1
;
// od Javy 17 jest też wersja dla przedziału domkniętego od, do
// int z = random.nextInt(1, 10);
System
.
out
.
println
(
"Ile to jest "
+
x
+
" × "
+
y
+
" ?"
);
Scanner
scanner
=
new
Scanner
(
System
.
in
);
int
odp
=
scanner
.
nextInt
();
if
(
odp
==
x
*
y
)
{
System
.
out
.
println
(
"Poprawna odpowiedź"
);
}
else
{
System
.
err
.
println
(
"Błędna odpowiedź"
);
}
System
.
out
.
println
(
x
+
" × "
+
y
+
" = "
+
x
*
y
);
}
}
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