FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java-Programming/Assignment-2/FloatCompare.java at master · SHembram18/Java-Programming · GitHub
SHembram18
Java-Programming
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Java-Programming
/
Assignment-2
/
FloatCompare.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
45 lines (30 loc) · 992 Bytes
Breadcrumbs
Java-Programming
/
Assignment-2
/
FloatCompare.java
Copy path
File metadata and controls
45 lines (30 loc) · 992 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
* PROGRAM : Write a java Program to compare two floating point values given as run time input upto 3 decimal places
* FILE : FloatCompare.java
* CREATED BY: Santosh Hembram
* DATED : 07-08-20
*/
class
FloatCompare
{
public
static
void
main
(
String
[]
args
) {
if
(
args
.
length
<
2
)
System
.
out
.
println
(
"====================
\n
INSUFFICIENT NO. OF ARGUMENTS===================="
);
else
{
double
x
,
y
;
x
=
Double
.
parseDouble
(
args
[
0
]);
y
=
Double
.
parseDouble
(
args
[
1
]);
System
.
out
.
print
(
"Input two floating-point number: "
);
x
=
Math
.
round
(
x
*
1000
);
x
=
x
/
1000
;
y
=
Math
.
round
(
y
*
1000
);
y
=
y
/
1000
;
if
(
x
==
y
)
{
System
.
out
.
println
(
"They are the same up to three decimal places"
);
}
else
{
System
.
out
.
println
(
"They are different"
);
}
}
}
}
Back
|
FazBrowse Home
|
New Git URL