File tree 2 files changed +50
-0
lines changed
2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ import java .lang .*;
2
+ import java .util .*;
3
+ import java .io .*;
4
+ class MinMaxNorm
5
+ {
6
+ public static void main (String [] args ) throws Exception
7
+ {
8
+ BufferedReader in = new BufferedReader (new FileReader ("C://Users/it/Desktop/data.txt" ));
9
+
10
+ String inputLine = in .readLine ();
11
+ String [] fields = inputLine .split (" " ); // Splits at the space
12
+ int i =0 ;
13
+ int [] arr =new int [fields .length ];
14
+ for (String str :fields ){
15
+ int x =Integer .parseInt (str ); //prints out name
16
+ arr [i ++]=x ;
17
+ }
18
+ for (int a :arr )
19
+ {
20
+ System .out .println (a );
21
+ }
22
+ int max1 =Integer .MIN_VALUE ;
23
+ int min1 =Integer .MAX_VALUE ;
24
+ for ( i =0 ;i <arr .length ;i ++)
25
+ {
26
+ if (arr [i ]>max1 )
27
+ max1 =arr [i ];
28
+ }
29
+ System .out .println (max1 );
30
+ for ( i =0 ;i <arr .length ;i ++)
31
+ {
32
+ if (arr [i ]<min1 )
33
+ min1 =arr [i ];
34
+ }
35
+ System .out .println (min1 );
36
+ int max2 =1 ;
37
+ int min2 =0 ;
38
+ double normArray []=new double [arr .length ];
39
+ for ( i =0 ;i <arr .length ;i ++)
40
+ {
41
+ normArray [i ]=(double )((double )(arr [i ]-min1 )/(double )(max1 -min1 ));
42
+
43
+ }
44
+ for ( i =0 ;i <arr .length ;i ++)
45
+ {
46
+ System .out .println (arr [i ]+"---Normalized value-->" +normArray [i ]);
47
+ }
48
+ }
49
+ }
Original file line number Diff line number Diff line change
1
+ 1000 2000 3000 5000 9000
You can’t perform that action at this time.
0 commit comments