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
99b56463
Commit
99b56463
authored
Nov 05, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wymiary pokoju
parent
e95e0ea2
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
90 additions
and
0 deletions
+90
-0
Skaner1.java
src/main/java/p03_interakcja/skaner/Skaner1.java
+18
-0
WymiaryPokoju.java
src/main/java/p03_interakcja/skaner/WymiaryPokoju.java
+25
-0
WymiaryPokojuD.java
src/main/java/p03_interakcja/skaner/WymiaryPokojuD.java
+21
-0
WymiaryPokojuUS.java
src/main/java/p03_interakcja/skaner/WymiaryPokojuUS.java
+26
-0
No files found.
src/main/java/p03_interakcja/skaner/Skaner1.java
View file @
99b56463
...
...
@@ -27,6 +27,24 @@ public class Skaner1 {
System
.
out
.
println
(
x
+
" razy "
+
y
+
" = "
+
x
*
y
);
System
.
out
.
printf
(
"%d razy %d = %d\n"
,
x
,
y
,
x
*
y
);
System
.
out
.
println
(
"Wpisz liczbę z przecinkiem (!):"
);
double
d
=
scanner
.
nextDouble
();
System
.
out
.
println
(
"Liczby: "
+
x
+
" , "
+
d
);
System
.
out
.
print
(
"Wpisz dwa słowa: "
);
String
slowo1
=
scanner
.
next
();
String
slowo2
=
scanner
.
next
();
System
.
out
.
println
(
"Pierwsze: "
+
slowo1
);
System
.
out
.
println
(
"Drugie : "
+
slowo2
);
// Gdy teraz wczytam "linię" co tam będzie? Reszta linii wpisana za tymi ↑ dwoma słowami
linia
=
scanner
.
nextLine
();
System
.
out
.
println
(
"Linia zawiera: "
+
linia
);
System
.
out
.
println
(
"KONIEC"
);
// Teoretycznie Scanner jest zasobem i należałoby go zamknąć,
// ale w praktyce, jeśli chodzi o System.in, to niezamknięcie nie jest błędem; nic złego by się nie stało.
scanner
.
close
();
...
...
src/main/java/p03_interakcja/skaner/WymiaryPokoju.java
0 → 100644
View file @
99b56463
package
p03_interakcja
.
skaner
;
import
java.util.Scanner
;
/* Użytkownik podaje wymiary pomieszczenia: wysokość i szerokość.
Program oblicza pole powierzchni oraz obwód.
(można wykorzystać np. podczas kupowania paneli i listew podłogowych)
*/
public
class
WymiaryPokoju
{
public
static
void
main
(
String
[]
args
)
{
Scanner
sc
=
new
Scanner
(
System
.
in
);
System
.
out
.
println
(
"Podaj wymiary pomieszczenia"
);
System
.
out
.
print
(
" * długość: "
);
int
a
=
sc
.
nextInt
();
System
.
out
.
print
(
" * szerokość: "
);
int
b
=
sc
.
nextInt
();
int
pole
=
a
*
b
;
int
obwod
=
2
*
a
+
2
*
b
;
System
.
out
.
printf
(
"Pole jest równe %d m² a obwód %d mb.\n"
,
pole
,
obwod
);
}
}
src/main/java/p03_interakcja/skaner/WymiaryPokojuD.java
0 → 100644
View file @
99b56463
package
p03_interakcja
.
skaner
;
import
java.util.Scanner
;
public
class
WymiaryPokojuD
{
public
static
void
main
(
String
[]
args
)
{
Scanner
sc
=
new
Scanner
(
System
.
in
);
System
.
out
.
println
(
"Podaj wymiary pomieszczenia"
);
System
.
out
.
print
(
" * długość: "
);
double
a
=
sc
.
nextDouble
();
System
.
out
.
print
(
" * szerokość: "
);
double
b
=
sc
.
nextDouble
();
double
pole
=
a
*
b
;
double
obwod
=
2
*
a
+
2
*
b
;
System
.
out
.
printf
(
"Pole jest równe %.3f m² a obwód %.3f mb.\n"
,
pole
,
obwod
);
}
}
src/main/java/p03_interakcja/skaner/WymiaryPokojuUS.java
0 → 100644
View file @
99b56463
package
p03_interakcja
.
skaner
;
import
java.util.Locale
;
import
java.util.Scanner
;
public
class
WymiaryPokojuUS
{
public
static
void
main
(
String
[]
args
)
{
// w tym programie zanim stworzę Scanner i użyję printf, zmieniam ustawienia językowe na US
// Dzięki temu separatorem dziesiętnym będzie kropka.
Locale
.
setDefault
(
Locale
.
US
);
Scanner
sc
=
new
Scanner
(
System
.
in
);
System
.
out
.
println
(
"Podaj wymiary pomieszczenia"
);
System
.
out
.
print
(
" * długość: "
);
double
a
=
sc
.
nextDouble
();
System
.
out
.
print
(
" * szerokość: "
);
double
b
=
sc
.
nextDouble
();
double
pole
=
a
*
b
;
double
obwod
=
2
*
a
+
2
*
b
;
System
.
out
.
printf
(
"Pole jest równe %.3f m² a obwód %.3f mb.\n"
,
pole
,
obwod
);
}
}
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