Newsletter sign-up
View all newsletters

Sign up for our Enterprise Java Newsletter

Enterprise Java
JavaWorld Daily Brew

Core Java


package programs;

import java.io.*;
import java.util.*;

public class pred {
static int i;
static String[]list = new String[100];
public static void main(String[] args) throws IOException,NullPointerException {
//InputStreamReader in = new InputStreamReader(null, "in.txt");
//OutputStreamWriter out = new OutputStreamWriter(null, "out.txt");
Scanner in = new Scanner(FileInputStream("in.txt"));
PrintWriter out = new PrintWriter(FileWriter("out.txt"));
String[]num = new String[100];
int z = 0;
String str = in.next();
while(!(str.equals("$$$$$"))) {
list[z] = str;
num[z] = getWord(str);
z++;
str = in.next();
}
insertionSort(list,0,z);
for(int i=0;i=lo && key.compareToIgnoreCase(list[k])<0){
list[k+1] = list[k];
--k;
}
list[k+1] = key;
}

}
public static String getWord(String Word){
String word = null;
int l = word.length();
String str = " ";
char y = word.charAt(i);
if(y=='a'||y=='b'||y=='c'){
str+=2;
}
if(y=='d'||y=='e'||y=='f'){
str+=3;
}
if(y=='g'||y=='h'||y=='i'){
str+=4;
}
if(y=='j'||y=='k'||y=='l'){
str+=5;
}
if(y=='m'||y=='n'||y=='o'){
str+=5;
}
if(y=='p'||y=='q'||y=='r'||y=='s'){
str+=5;
}
if(y=='t'||y=='u'||y=='v'){
str+=5;
}
if(y=='w'||y=='x'||y=='y'||y=='z'){
str+=5;
}
return str;
}

private static BufferedReader FileInputStream(String string) {
// TODO Auto-generated method stub
return null;
}
}

Your rating: None Average: 3 (1 vote)

Debugging of the problem

In public string gerword(String word)
there is no proper relation given in if statement giving char = 'a' which u stated previously the char y=word.charAt[i].
which is in proper
The remaing part i will tell when I logg in as my time is up ok

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <p> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <br /> <br> <strike>
  • Lines and paragraphs break automatically.
  • Use <!--pagebreak--> to create page breaks.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
Just checking to see if you're an actual person rather than a spammer. Sorry for the inconvenience.