File tree Expand file tree Collapse file tree 1 file changed +12
-13
lines changed Expand file tree Collapse file tree 1 file changed +12
-13
lines changed Original file line number Diff line number Diff line change 1
- package soundex ;
2
-
3
- import java .util .Scanner ;
4
-
5
1
public class Soundex {
6
2
7
- public static String soundex (String str ) {
3
+ public static void soundex (String str ) {
8
4
9
5
char [] s = str .toUpperCase ().toCharArray ();
10
6
//retaining first letter
@@ -30,7 +26,7 @@ public static String soundex(String str) {
30
26
case 'Z' :
31
27
s [i ] = '2' ;
32
28
break ;
33
-
29
+
34
30
case 'D' :
35
31
case 'T' :
36
32
s [i ] = '3' ;
@@ -64,15 +60,18 @@ public static String soundex(String str) {
64
60
65
61
// right padding with zeroes or truncating
66
62
output = output + "0000" ;
67
- return output .substring (0 , 4 );
63
+ System . out . println ( str + " : " + output .substring (0 , 4 ) );
68
64
}
69
65
70
66
public static void main (String [] args ) {
71
67
72
- Scanner sc = new Scanner (System .in );
73
- System .out .println ("Enter the string" );
74
- String str = sc .nextLine ();
75
- String str_output = soundex (str );
76
- System .out .println (str_output );
68
+ String str1 = "Dear" ;
69
+ String str2 = "Deer" ;
70
+ String str3 = "Ashcraft" ;
71
+ String str4 = "Ashcroft" ;
72
+ soundex (str1 );
73
+ soundex (str2 );
74
+ soundex (str3 );
75
+ soundex (str4 );
77
76
}
78
- }
77
+ }
You can’t perform that action at this time.
0 commit comments