Write a program that takes a word from the keyboard, reverses it and prints the reversed word to the monitor.
This is what I need to do...I have done this thus far: import java.io* public class Reverse{ static BufferedReader keyboard=new BufferedReader(new InputStreamReader(System.in));
public static void main(String args[])throws IOException {
prompt("Please enter a word: "); String myWord = keyboard.readLine(); display(myWord); exitProgram(); }
public static String getWord(String myWord)throws IOException { int length = myWord.length(); String newWord = ""; if(!myWord.equals("")) { for(int i = length - 1; i>=0; i--) { newWord += myWord.charAt(i);
} }
return myWord;}}
I can't get it to work...can anyone help me??? It simply returns the word the user inputs.
Hello John.. I have debugged your programe Now its working fine.. If you want you can have input and output in infinite loop ,where you will get output without exiting.