Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
javab_20230617
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
javab_20230617
Commits
7e0ab3b7
Commit
7e0ab3b7
authored
Jul 01, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Kalkulator - wiele działań
parent
6d75f364
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
9 deletions
+15
-9
Kalkulator.java
...-Servlety/src/main/java/serwlety/podstawy/Kalkulator.java
+15
-9
No files found.
PC23-Servlety/src/main/java/serwlety/podstawy/Kalkulator.java
View file @
7e0ab3b7
...
@@ -18,7 +18,7 @@ public class Kalkulator extends HttpServlet {
...
@@ -18,7 +18,7 @@ public class Kalkulator extends HttpServlet {
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<html>
<head>
<head>
<title>
Rozmowa serlwetowa
</title>
<title>
Kalulator serlwetowy
</title>
</head>
</head>
<body>"""
;
<body>"""
;
final
String
formularz
=
"""
final
String
formularz
=
"""
...
@@ -45,14 +45,20 @@ public class Kalkulator extends HttpServlet {
...
@@ -45,14 +45,20 @@ public class Kalkulator extends HttpServlet {
out
.
println
(
poczatek
);
out
.
println
(
poczatek
);
out
.
println
(
formularz
);
out
.
println
(
formularz
);
try
{
String
parametr1
=
request
.
getParameter
(
"liczba1"
);
long
liczba1
=
Long
.
parseLong
(
request
.
getParameter
(
"liczba1"
));
String
parametr2
=
request
.
getParameter
(
"liczba2"
);
long
liczba2
=
Long
.
parseLong
(
request
.
getParameter
(
"liczba2"
));
String
operacja
=
request
.
getParameter
(
"operacja"
);
String
operacja
=
(
request
.
getParameter
(
"operacja"
));
if
(
parametr1
!=
null
&&
!
parametr1
.
isBlank
()
long
wynik
=
oblicz
(
liczba1
,
liczba2
,
operacja
);
&&
parametr2
!=
null
&&
!
parametr1
.
isBlank
()
out
.
println
(
"<div>Wynik "
+
wynik
+
"</div>"
);
&&
operacja
!=
null
&&
!
operacja
.
isBlank
())
{
}
catch
(
NumberFormatException
e
)
{
try
{
out
.
println
(
"Niepoprawny format liczby"
);
long
liczba1
=
Long
.
parseLong
(
parametr1
);
long
liczba2
=
Long
.
parseLong
(
parametr2
);
long
wynik
=
oblicz
(
liczba1
,
liczba2
,
operacja
);
out
.
printf
(
"<div>%d %s %d = <strong>%d</strong></div>"
,
liczba1
,
operacja
,
liczba2
,
wynik
);
}
catch
(
NumberFormatException
e
)
{
out
.
println
(
"Niepoprawny format liczby"
);
}
}
}
out
.
println
(
koniec
);
out
.
println
(
koniec
);
...
...
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