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
f04326a3
Commit
f04326a3
authored
Nov 05, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Przykład zakupy
parent
0a9626c7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
Zakupy.java
src/main/java/p01_zmienne/Zakupy.java
+30
-0
No files found.
src/main/java/p01_zmienne/Zakupy.java
0 → 100644
View file @
f04326a3
package
p01_zmienne
;
import
javax.swing.JOptionPane
;
/*
Program zadaje trzy pytania:
- Co chcesz kupić (użytkownik podaje nazwę towaru)
- Ile kosztuje jedna sztuka
- Ile sztuk kupujesz
Następnie program oblicza, jaka będzie kwota do zapłaty, i wypisuje komunikat postaci
Za 6 sztuk towaru kapusta zapłacisz 12.0 zł.
(tutaj wpisuję przykładową nazwę i cenę, a program ma wpisać dane podane przez usera)
*/
public
class
Zakupy
{
public
static
void
main
(
String
[]
args
)
{
String
towar
=
JOptionPane
.
showInputDialog
(
"Co chcesz kupić?"
);
double
cena
=
Double
.
parseDouble
(
JOptionPane
.
showInputDialog
(
"Ile kosztuje jedna sztuka "
+
towar
+
"?"
));
int
sztuk
=
Integer
.
parseInt
(
JOptionPane
.
showInputDialog
(
"Podaj liczbę sztuk"
));
double
kwota
=
cena
*
sztuk
;
JOptionPane
.
showMessageDialog
(
null
,
"Za "
+
sztuk
+
" sztuk towaru "
+
towar
+
" zapłacisz "
+
kwota
+
" zł"
);
// wersja zaokrąglająca wynik:
JOptionPane
.
showMessageDialog
(
null
,
String
.
format
(
"Za %d sztuk towaru %s zapłacisz %.2f"
,
sztuk
,
towar
,
kwota
));
}
}
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