English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Write a program called URL, that reads from the standard input, keyboard input, a commercial web site URL. You should expect that the URL starts with www and ends with .com After reading the input you should out the url . excluding the www. and the .com

Sample Input
Please enter a url:
www.yahoo.com

Sample output
yahoo

2007-03-16 06:52:03 · 3 answers · asked by LULU 1 in Computers & Internet Programming & Design

3 answers

Here is a method for getting input from the user...

public String getUserInput() {
String inputLine = null;
try {
BufferedReader is = new BufferedReader(new InputStreamReader(System.in));
inputLine = is.readLine();
if(inputLine.length()==0) return null;
} catch (IOException e) {
System.out.println("IOException: "+e);
}
return inputLine.toLowerCase().trim();
}

As for taking sub-strings out of a string, reference the Java libraries specifically the String class. I would imagine you would use ".substring(x,y)" amongst other methods.

2007-03-16 07:03:16 · answer #1 · answered by Christina 2 · 0 0

better yet just use the variable names of the input

2007-03-16 14:26:10 · answer #2 · answered by the_rock55_2001 3 · 0 0

how about you try to do it yourself and if you have problems, then you ask?

2007-03-16 19:41:23 · answer #3 · answered by icnintel 4 · 0 0

fedest.com, questions and answers