File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change
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 ("====================\n INSUFFICIENT 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
+
You can’t perform that action at this time.
0 commit comments