Skip to content

Commit f0e770d

Browse files
authored
Add files via upload
1 parent d99f95c commit f0e770d

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

Assignment-2/FloatCompare.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* PROGRAM : Write a java Program to compare two floating point values given as run time input upto 3 decimal places
3+
* FILE : FloatCompare.java
4+
* CREATED BY: Santosh Hembram
5+
* DATED : 07-08-20
6+
*/
7+
class FloatCompare{
8+
9+
public static void main(String[] args) {
10+
11+
if(args.length < 2)
12+
System.out.println("====================\nINSUFFICIENT NO. OF ARGUMENTS====================");
13+
14+
else{
15+
16+
double x,y;
17+
18+
x = Double.parseDouble(args[0]);
19+
y = Double.parseDouble(args[1]);
20+
21+
System.out.print("Input two floating-point number: ");
22+
23+
24+
x = Math.round(x * 1000);
25+
x = x / 1000;
26+
27+
y = Math.round(y * 1000);
28+
y = y / 1000;
29+
30+
if (x == y)
31+
{
32+
System.out.println("They are the same up to three decimal places");
33+
}
34+
else
35+
{
36+
System.out.println("They are different");
37+
}
38+
39+
}
40+
}
41+
}
42+
43+
44+
45+

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy