Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
simple_java
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
simple_java
Commits
9d9a86b1
Commit
9d9a86b1
authored
Dec 13, 2025
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Program korzytsający z Konto
parent
5a0a5e76
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
1 deletions
+56
-1
Main.java
src/main/java/com/example/Main.java
+56
-1
No files found.
src/main/java/com/example/Main.java
View file @
9d9a86b1
package
com
.
example
;
import
java.util.Scanner
;
public
class
Main
{
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
"Hello world!"
);
@SuppressWarnings
(
"resource"
)
Scanner
sc
=
new
Scanner
(
System
.
in
);
System
.
out
.
print
(
"Przedstaw się: "
);
String
osoba
=
sc
.
nextLine
();
System
.
out
.
print
(
"Podaj początkową kwotę: "
);
int
kwota
=
sc
.
nextInt
();
sc
.
nextLine
();
// wymuszenie przejścia do nowej linii
Konto
konto
=
new
Konto
(
1
,
kwota
,
osoba
);
System
.
out
.
println
(
konto
);
petla:
while
(
true
)
{
try
{
System
.
out
.
println
(
"Co chcesz zrobić? W - wpłata, Y - wypłata, K - koniec"
);
String
wybor
=
sc
.
nextLine
().
toUpperCase
();
switch
(
wybor
)
{
case
"K"
,
"Q"
->
{
break
petla
;
// przejście do Koniec programu
}
case
"W"
->
{
System
.
out
.
print
(
"Podaj kwotę wpłaty: "
);
kwota
=
sc
.
nextInt
();
sc
.
nextLine
();
konto
.
wplata
(
kwota
);
System
.
out
.
println
(
"Pieniądze zostały wpłacone"
);
}
case
"Y"
->
{
System
.
out
.
print
(
"Podaj kwotę wypłaty: "
);
kwota
=
sc
.
nextInt
();
sc
.
nextLine
();
konto
.
wyplata
(
kwota
);
// ta linia wykona się tylko jeśli nie było wyjątku:
System
.
out
.
println
(
"Pieniądze zostały wypłacone"
);
}
default
->
{
System
.
out
.
println
(
"Nieznane polecenie"
);
continue
petla
;
// Przejście do Co chcesz zrobić
}
}
}
catch
(
IllegalArgumentException
e
)
{
System
.
out
.
println
(
"Niepoprawny argument: "
+
e
.
getMessage
());
}
catch
(
BrakSrodkow
e
)
{
System
.
out
.
println
(
e
.
getMessage
());
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"Inny błąd: "
+
e
);
}
System
.
out
.
println
();
System
.
out
.
println
(
konto
);
System
.
out
.
println
();
}
System
.
out
.
println
(
"Koniec programu"
);
}
}
\ No newline at end of file
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